2014-03-01 3 views
0

AngularJS를 사용하는 다른 지시문 안에 지시문이 있습니다. 호출 된 제목 ({{questions.n3.name}})이 표시되지 않습니다. 여기 AngularJS (지시어 내 지시문)에 제목이 표시되지 않습니다.

내 JS의 :

.directive('myRating', function() { 

return{ 
    restrict: 'E', 
    template: '<div><div class="row question">{{questions.n3A.name}}</div> \ 
       <div class="row rating" ng-controller="RatingDemoCtrl"> \ 
       <rating value="rate" max="max" readonly="isReadonly" state-on="\'glyphicon-star rated\'" state-off="\'glyphicon-star\'"></rating> \ 
        <div class="col-md-12"> \ 
        <button class="btn btn-sm btn-danger form-control" ng-click="rate = 0" ng-disabled="isReadonly">Clear</button> \ 
        </div> \ 
       </div> \ 
       </div>', 
    replace: true, 
    scope: { 
     text: '@' 
    } 
}; 


}); 

$scope.questions = { 
"n3A": { 
    "name": "How safe did you feel on your trip?", 
    "ID": "n3A" 
}, 
"n3B": { 
    "name": "How did you get there?", 
    "ID": "n3B" 
}, 

};

나는 또한 Pluncker을 만들었습니다. 예 및 남미/아시아/아프리카를 클릭하면 제목이 별 위에 표시됩니다.

내가 누락 된 부분이 있으십니까?

답변

1

당신은 scope: {text: '@'}

와 그 방법을 지침의 고립 된 영역을 작성, 지시어는 scope.questions 변수가 참조하는 일에 대해 아무 생각이 없습니다.

myRating 지시문 선언에서 scope 속성을 제거하면 작동합니다.

관련 문제