2017-03-23 4 views
0

컨트롤러 'appContent'에 필요한 컨트롤러 'appLeft'을 찾을 수 없습니다!각도 지시문 - 컨트롤러를 찾을 수 없습니다.

//app-nav(left) 
    app.directive('appLeft', function() 
    { 
     return { 
      restrict: 'E', 
      replace: false, 
      scope: { 
       leftItem: "=leftItem" 
      }, 
      controller:function($scope){ 
       this.title = $scope.leftItem; 
      }, 
      templateUrl: 'res/tpl/app-left.html', 
      link: function (scope, ele, attr) 
      { 
       scope.toggle=function(index){ 
        scope.leftItem[index].isShow = !scope.leftItem[index].isShow; 
       } 
      } 
     } 
    }); 
    //app-content 
    app.directive('appContent',function(){ 
     return { 
      require:'^appLeft', 
      restrict: 'E', 
      replace:false, 
      transclude:true, 
      scope:{}, 
      templateUrl:'res/tpl/app-content.html', 
      link:function(scope,ele,attr,appLeftCtrl){ 
       console.log(appLeftCtrl.title) 
      } 
     } 
    }); 

컨트롤러 'appContent'에 필요한 컨트롤러 'appLeft'을 (를) 찾을 수 없습니다!

+0

당신은 당신의 HTML 코드를 추가 할 수 있을까요? HTML에 지시어를 어떻게 두 었는가? –

답변

0

appLef 지시문이 상위 지시문이므로 필수 지시문이 html DOM의 하위 지시문 외부에 있는지 확인하십시오. 지정된 컨트롤러가 발견되지 않는 한

<app-left> 
    <app-content></app-content> 
</app-left> 

지시어가 필요합니다 문서

에 따르면, $ 컴파일 오류가 발생합니다.^접두사는이 지시어가 부모에있는 컨트롤러를 검색한다는 것을 의미합니다 (^ 접두사없이 지시어는 컨트롤러 자체의 요소를 찾습니다).

Demo

관련 문제