कृपया उदाहरण hereAngularJS निर्देश: पृथक गुंजाइश और attrs
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);
...
कोणीय जरूरतों symbol
, max
, readonly
माता पिता दायरे से उस तक पहुंच पृथक गुंजाइश वस्तु में परिभाषित किया जा करने के लिए देखते हैं।
यह here
<fm-rating ng-model="$parent.restaurant.price" symbol="$" readonly="true"></fm-rating>
प्रयोग किया जाता है तो, attrs
के उद्देश्य क्या है? attrs
के माध्यम से पारित सभी विशेषताओं तक पहुंच नहीं सकता है। scope.max
के बजाय अधिकतम attrs.max
के मूल्य का अधिकतम उपयोग क्यों नहीं कर सकता है attrs.max = scope.max
की तरह वापस क्यों असाइन करें?
चूंकि यह ऐप कोणीय लेखकों द्वारा लिखा गया है, इसलिए मुझे एक कारण की उम्मीद है।
धन्यवाद।
यहां एक नज़र डालें http://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope/14063373#14063373 –