angular1.x 至少三种实现不同模块之间通信方式?以及改善Angular 性能

  • Service

  • events,指定绑定的事件

  • 使用 $rootScope

  • controller之间直接使用$parent$$childHead

  • directive 指定属性进行数据绑定

改善Angular 性能

官方提倡的,关闭debug,$compileProvider

myApp.config(function ($compileProvider) {  
  $compileProvider.debugInfoEnabled(false);
});

使用一次绑定表达式即{{::yourModel}}
减少watcher数量
在无限滚动加载中避免使用ng-repeat,关于解决方法可以参考这篇文章
使用性能测试的小工具去挖掘你的angular性能问题,我们可以使用简单的console.time()也可以借助开发者工具以及Batarang
console.time("TimerName");  
//your code
console.timeEnd("TimerName");  

猜你喜欢

转载自blog.csdn.net/xuehu837769474/article/details/80491453
今日推荐