directive完成UI渲染后执行JS

ui-view有相应的$viewContentLoaded

http://blog.csdn.net/xinshangshangxin/article/details/44700813

ng-repeat - 再写一个指令判断上层scope.$last === true

http://www.cnblogs.com/tanxu/p/5527338.html

自定义指令 - link内部使用timeout,将callback丢到队列最后执行

https://segmentfault.com/a/1190000004267696?_ea=551513

directive的link函数如下:

directive("format", ["$timeout", function(timer) {
    return {
      link: function($scope, elem, attr) {
        timer(function() {
          var val = elem.text();
          console.log(val);
          var val = parseFloat(val);
          if (val !== val) {
            return
          }
          elem.text(val.toFixed(3));
        }, 0);
      },
      restrict: "A",
    }
  }]);

link会完成绑定和渲染,只要保证我们的callback排在后面就可以了。

原文地址:https://www.cnblogs.com/wancy86/p/6748128.html