在數據準備就緒之前,我需要檢測一個出現ngRepeat
的時刻。Catch ngRepeat初始化事件
我試過使用compile
(它爲ngRepeat啓動一次),但仍然沒有運氣,它在數據準備好後觸發。
目標是在父指令上設置加載微調器。並在數據準備就緒時將其刪除。
猜測我可以使用父郵件鏈接來搜索孩子的指令,但它不是角度的方式。
這裏是plunker https://plnkr.co/edit/5OY5ySZm5L6Ba5Vw17af?p=preview
function testDirective(){
return {
compile: function compile(){
console.log('on data ready too, but I want it to be fired on init');
return {
pre: function(scope){
if(scope.$first){
console.log('first');
}
if(scope.$last){
console.log('last');
}
}
};
}
}
}
這也不是角度的方式。在此處添加您的代碼或者獲得幫助。 –
......這是什麼? ngRepeat的用法?好。 – Kindzoku
@VassilisPits一樣好 – Kindzoku