템플릿을 인라인에서 자체 파일로 이동하려고합니다. 왜 내 템플릿 test.html를에 tAttrs
을AngularJS 지시문이 templateUrl 함수를 통해 매개 변수를 전달합니다.
{{ 'content.' + tAttrs.edit + '.data' }}
<button ng-click="' + tAttrs.edit + '_form'+ '.$show()" ng-hide="' + tAttrs.edit + '_form'+ '.$visible">edit</button>
전달되지 않는 내가 templateUrl
Glenn.directive('test', function($compile) {
return {
restrict: 'A',
priority: 1000,
terminal: true,
templateUrl: function(tElement, tAttrs) {
return ('test.html');
},
link: function(scope, element, attrs) {
attrs.$set('editable-text', 'content.' + attrs.edit + '.data');
attrs.$set('edit', null);
$compile(element)(scope);
}
}
});
인 test.html로 템플릿을 변경하기 전에 모든 작업을했다?
myApp.directive('fooDirective', function(){
return{
restrict: 'E',
scope: true,
templateUrl: './foodirective.tmpl.html',
link: function(scope, elem, attrs){
// do stuff
scope.tAttrs = attrs;
}
}
})
I :
나는이 그런 식으로 본 적이
코드로 JSFiddle it Plunker를 게시 할 수 있습니까? 당신이하려고하는 것을 말하기는 어렵습니다. – GFoley83
제가하려는 것은 속성 값을 템플릿에 전달하는 것입니다. –