!!!!!!!!!! 이전 질문
code (구식 인)을보십시오. 템플릿이있는 격리 된 지시문은 작동하지만보기에서 액세스하는 지시문은 작동하지 않습니다. 반투명 격리 지시문 컨트롤러 모델이보기에서 액세스 할 수 없음
는 새로운 하나
나는 같은 plunk 사용하고 난 내 지시어에, 그러나 그것은 여전히 작동하지 않는 transclution를 사용하는 앤드류 아이젠 버그의 제안을 듣고있다.
HTML
<p isolate-with-template></p>
<p isolate-with-transclude>Hello World {{vm.hi}}</p>
JS
angular.module('app',[])
.directive('isolateWithTemplate',function() {
return {
restrict: 'A',
controllerAs: 'vm',
scope:{},
controller: function ($scope) {
var vm = this;
vm.hi = "hi";
},
template: "{{vm.hi}}"
}
})
.directive('isolateWithTransclude',function() {
return {
restrict: 'A',
controllerAs: 'vm',
scope: {},
transclude: true,
template: "<div ng-transclude></div>",
controller: function ($scope) {
var vm = this;
vm.hi = "hi";
}
}
})
고립 된 스코프 지시자는 템플릿이 – charlietfl