我试图抓住$ last属性,以便在ng-repeat完成时收到通知.我已经为此创建了特殊指令(ngRepeatDoneNotification).Ng-repeat适用于另一个元素指令(单位).因此,有一个带有三个指令的结构:
<unit ng-repeat="unit in collection" ng-repeat-done-notification id="{{unit.id}}"></unit>
Run Code Online (Sandbox Code Playgroud)
一旦我将范围设置为隔离,$ last就会在我的通知程序指令中消失.
App.directive('ngRepeatDoneNotification', function() {
return function(scope, element, attrs) {
if (scope.$last){ // ISSUE IS HERE
window.alert("im the last!");
}
};
});
App.directive('unit', function() {
return {
restrict: 'E',
replace: true,
scope: {id: '@'}, // ONCE I ISOLATE SCOPE, $last DISAPPEARED
templateUrl: '/partials/unit.html',
link: function(scope, element) {}
}
});
Run Code Online (Sandbox Code Playgroud)
我创建了jsFiddle http://jsfiddle.net/4erLA/1/
怎么可能抓到这个?