Created
September 26, 2016 10:25
-
-
Save zhuangya/38476c504d29d39d8d2bfae5e11b5060 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="ing"> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-gettext/2.3.8/angular-gettext.js"></script> | |
</head> | |
<body> | |
<h1>watch typeof</h1> | |
<div ng-controller="MainCtrl"> | |
<p> <strong>without workaround</strong> </p> | |
<input type="range" ng-model="activity.length" min="1" max="10" step="1"> <span translate translate-n="activity.length" translate-plural="{{$count}} hours">1 hour</span> | |
<strong> typeof activity.length is: {{activity.length|typeof}} </strong> | |
<hr /> | |
<p><strong> with workaround </strong></p> | |
<input type="range" ng-model="activity.length" min="1" max="10" step="1"> <span translate translate-n="getLength()" translate-plural="{{$count}} hours">1 hour</span> | |
<strong> typeof getLength() is: {{getLength()|typeof}} </strong> | |
</div> | |
<script> | |
angular.module('ing', ['gettext']) | |
.filter('typeof', function () { | |
return function (input) { | |
return typeof input; | |
} | |
}) | |
.controller('MainCtrl', function ($scope) { | |
$scope.getLength = function () { | |
return Number($scope.activity.length); | |
} | |
$scope.activity = { | |
length: 3 | |
}; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment