2014-07-23 4 views
1

템플릿을 인라인에서 자체 파일로 이동하려고합니다. 왜 내 템플릿 test.html를에 tAttrsAngularJS 지시문이 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 :

나는이 그런 식으로 본 적이
+0

코드로 JSFiddle it Plunker를 게시 할 수 있습니까? 당신이하려고하는 것을 말하기는 어렵습니다. – GFoley83

+0

제가하려는 것은 속성 값을 템플릿에 전달하는 것입니다. –

답변

4

, 난 항상 당신은 연결 기능에 지시문 요소에서 바인드합니다을 할당 할 수

... 
templateUrl: './foodirective.tmpl.html' 
... 

처럼 templateUrl 속성에 문자열을 전달 plunk을 준비했습니다.

+0

이것이 왜 나에게 효과가 있는지 모르겠습니다. 난 그냥 내 템플릿'tAttrs.edit'에 반환 된 null을 얻습니다. ( –

+0

> 내 노력은 속성 값을 템플릿에 전달하는 것입니다. [plunk] (http://plnkr.co/edit/6Oh0l7JyKoFZif2pnHuK?p=preview)? – miron

관련 문제