I'm having an issue trying to make an Angular Directive in Typescript after a ng-repeat
finish.
This is how I'm trying to make the directive work:
export interface ILightSliderInitDirectiveScope extends ng.IScope {
}
export class LightSliderInitDirective implements ng.IDirective {
public static DirectiveName: string = "lightSliderInit";
link = (scope: ILightSliderInitDirectiveScope, $element: any, attrs: ng.IAttributes) => {
if (scope.$watch('$scope.$last'))
scope.$emit('ngRepeatFinished');
}
}
At the controller I have this method:
_self.$scope.$on('ngRepeatFinished', function() {...});
And at the HTML:
<li ng-repeat="it in items" light-slider-init>...</li>
The problem is that the directive works, but it go inside the if condition in every iteration of the ng-repeat
.
How can I solve this?