我有一个指令,该指令的指令模板内有一个ng-repeat
。我希望来自ng-repeat
的数据来自嵌套指令的控制器。 ng-repeat没有运行...
指令模板
<div class="taskList" ng-repeat="task in taskList | orderBy : dueDate">
<div class="taskTopLine"></div>
<div ng-class="taskCircleClass" ng-style="changeCircle"
ng-click="completeTask(task); fillCircle(task)">
</div>
<div class="task-check" ng-show="showCheck"></div>
<p class="taskSubject" ng-click="goToTask(task); editTask(task)">
{{ task.name }}
</p>
</div>
指令
const taskItem = ($state, DataService, $rootScope, $uibModal, $window, $ngConfirm, inform) => {
return {
restrict: 'EA',
templateUrl: './app/views/directives/taskItem.directive.html',
scope: {
taskList: "="
},
link(scope, element, attrs) {
控制器
$scope.taskList = [];
DataService.getTasks().then(data => {
const temp = _.filter(data, o => { return moment(o.dueDate).isAfter(begin) && moment(o.dueDate).isBefore(end); });
$scope.client;
$scope.taskList = temp;
$scope.taskList.forEach((row, index) => {
row.sequence = index;
});
});
答案 0 :(得分:0)
问题出在ng-hide
,而不是ng-repeat