2013-05-20 2 views
50

나는 각도 JS 새로운 그리고 난 다음과 같이 사용됩니다 사용자 정의 지시어를 만들기 위해 노력하고 있어요 :Angular JS의 지시어 템플릿에서 "ng-repeat"를 사용하는 방법은 무엇입니까?

<div linkedlist listcolumns="{{cashAccountsColumns}}"></div>

Corrps합니다. 컨트롤러은 다음과 같습니다

$scope.cashAccountsColumns = [ 
    {"field": "description", "title": "Description"}, 
    {"field": "owner", "title":"Owner"}, 
    {"field": "currentBalance", "title":"Current Balance" } 
]; 

그리고 지시 코드은 다음과 같습니다는

return { 
     restrict : 'EA', 
     transclude : false, 
     templateUrl : 'html/linkedlist.html', 
     scope: { 
     listcolumns: "@" 
     }, 
     link : function(scope, element, attrs) { 
     } 
} 

템플릿 :

<table class="box-table" width="100%"> 
    <thead> 
    <tr> 
     <th scope="col" ng-repeat="column in listcolumns"> 
     {{column.title}} 
     </th> 
    </tr> 
    </thead> 
</table> 

하지만이 작동하지 않습니다. 내가 대신 아래 너무 많은 행이 DOM에 추가됩니다 화면에 column.title의 값을받지 못했습니다 :

<th ng-repeat="column in listcolumns" scope="col" class="ng-scope ng-binding"></th> 
+36

@Ajay beniwal 대답을 유용하다고 생각한다면 대답으로 표시하지 않으시겠습니까? – superjos

+1

원래의 포스터는 그가이 게시물 이후로 돌아온 것처럼 보이지 않습니다. – taco

답변

관련 문제