我有这个简单的指令:
myApp.directive('repeatDone', [function () {
return {
restrict: 'A',
link: function (scope, element, iAttrs) {
var parentScope = element.parent().scope();
if (scope.$last){
parentScope.$last = Math.random();
}
}
};
}]);
这是列表:
$scope.photos = [
{ filename: "6798453217_72dea2d06e_m.jpg", tags: "all,travel" },
{ filename: "7222046648_5bf70e893a_m.jpg", tags: "all,family" },
{ filename: "7002395006_29fdc85f7a_m.jpg", tags: "all,kids" },
{ filename: "7302459122_19fa1d8223_m.jpg", tags: "all,family" },
];
$scope.filterByTag = function(tag){
$scope.filters.tags = tag;
}
这是重复:
<a title="photos/{{photo.filename}}" ng-repeat="photo in photos | filter:filters" repeat-done>
<img src="photos/{{photo.filename}}" />
</a>
我有ng-clicks调用filterByTag函数,该函数成功过滤了照片数组,但是,每次过滤照片数组时都不会调用repeat-done指令,仅在&#34;某些&#34;倍。它不起作用的一个例子是当我尝试过滤所有&#34;然后&#34;家庭&#34;,照片消失了,但指令没有开火。
当ng-repeat完成创建项目时,我需要应用jquery插件,当然,当指令也没有时,它不起作用。也许我应该这样做,所以我愿意接受建议!谢谢!