Sto provando a catturare $ last property per essere notificato quando ng-repeat termina. Ho creato una direttiva speciale per questo (ngRepeatDoneNotification). Ng-repeat si applica alla direttiva di un altro elemento (unità). Quindi, v'è una costruzione con tre direttive:
<unit ng-repeat="unit in collection" ng-repeat-done-notification id="{{unit.id}}"></unit>
Una volta ho impostato portata ad essere isolato, $ lo scorso scomparve nella mia direttiva notificante.
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) {}
}
});
ho creo jsFiddle http://jsfiddle.net/4erLA/1/
Come è possibile raggiungere questo?
Non penso che tu possa avere un attributo 'id' dinamico come quello. – finishingmove