ので調べてみた。
安定のstackさん。ありがとうございます。
http://stackoverflow.com/questions/15207788/calling-a-function-when-ng-repeat-has-finished
まず、ngRepeatの終了を検知するディレクティブを定義。
var module = angular.module('testApp', [])
.directive('onFinishRender', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
$timeout(function () {
scope.$emit('ngRepeatFinished');
});
}
}
}
});
そしてngRepeatを用いていて、終了を検出したい要素に対して「on-finish-render」の属性を追加する。
最後にコントローラーから下記のようにイベントを実行させる。
$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
// 実行したい処理を記述
});
これ相当便利ですぜ。