var getter = $parse('user.name');
var setter = getter.assign;
var context = {user:{name:'angular'}};
var locals = {user:{name:'local'}};
expect(getter(context)).toEqual('angular');
setter(context, 'newValue');
expect(context.user.name).toEqual('newValue');
expect(getter(context, locals)).toEqual('local');
angular.module('toster', [])
.controller('MainCtrl', function($scope) {
$scope.data = {
price: 0,
count: 0
};
$scope.$watchCollection('data', function(data) {
var computed = 0;
var count = parseInt(data.count, 10);
if (count) {
computed = Math.round(data.price * count / 100);
}
$scope.computed = computed;
});
});
<p>Описание: {{product.description | limitTo:25}}</p>
Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see angular.Module) and it cannot be overridden by an Angular decorator.
angular.module('example').constant('config', {foo: 'bar'});