0
저는 AngularJS에서 지침을 배우고 있으며 격리 된 범위 (@, = 또는 &)를 추가 할 때 몇 가지 예를 발견했습니다. 때로는 격리 된 범위뿐만 아니라 그 뒤에 ngModel 이름을 추가합니다. 예 : "@"대신 "@name". 격리 된 범위 + 바인딩 이름과 격리 된 범위의 차이가 AngularJS에서만입니다.
myApp.directive('zippy', function() {
return {
restrict: "E",
transclude: true,
replace: true,
scope: {
name: "@" // <----
},
template: "<div>{{name}}<div ng-transclude></div></div>",
link: function(scope, element, attrs) {
console.log(scope.name);
}
}
});
그리고이 :
그래서 사이의 차이가 무엇
myApp.directive('zippy', function() {
return {
restrict: "E",
transclude: true,
replace: true,
scope: {
name: "@name" // <----
},
template: "<div>{{name}}<div ng-transclude></div></div>",
link: function(scope, element, attrs) {
console.log(scope.name);
}
}
});
Ohhhh i got it ... 이름 대신 "customerName"이 범위에 있다면 범위를 입력해야합니다. {customerName : '@name'}, 맞습니까? 하지만 scope 속성이 html "name"의 지시문과 정확히 같기 때문에 "@name"을 추가 할 필요가 없습니다. "@"를 직접 사용할 수 있습니다. :) – user3078876