See an example here.
foodMeApp.directive('fmRating', function() { return { restrict: 'E', scope: { symbol: '@', max: '@', readonly: '@' }, require: 'ngModel', link: function(scope, element, attrs, ngModel) { attrs.max = scope.max = parseInt(scope.max || 5, 10); ...
Angular requires symbol , max , readonly to define scope in an isolated object in order to access it from the parent scope.
used here
<fm-rating ng-model="$parent.restaurant.price" symbol="$" readonly="true"></fm-rating>
So what is the purpose of attrs ? Unable to access all attributes passed through attrs . Why is it impossible to get the max value as attrs.max instead of scope.max
Why assign back, for example attrs.max = scope.max ?
Since this app is written by Angular, I expect a reason.
thank.
javascript angularjs
bsr Jan 13 '13 at 5:35 2013-01-13 05:35
source share