Я новичок в Angular JS, и я пытаюсь создать настраиваемую директиву, которая будет использоваться ниже:
<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>
Но это не работает. Я не получаю значение column.title на экране, поэтому в DOM добавлено слишком много строк, как показано ниже:
<th ng-repeat="column in listcolumns" scope="col" class="ng-scope ng-binding"></th>