search

Home  >  Q&A  >  body text

angular.js - Angularjs通过父控制器向子控制器共享方法,中间通过路由,是否会严重影响性能

因为项目中各个router的controller中有很多重复的$scope.getName方法声明,想像下面描述一样把这些公共的部分放在路由外的controller里面。

<p  ng-controller="parentController">
    <p ui-view></p>
</p>

假设parentController中有一个方法叫$scope.getName;
而路由中配置的有个childController,此时在childController直接运行$scope.getName(person.name),是否会影响页面性能。

我想大声告诉你我想大声告诉你2744 days ago587

reply all(1)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:14:51

    There is a way to provide services in angular to achieve shared methods and reuse

    I have never practiced on performance issues, so I dare not speak nonsense.
    I feel like writing code like this is not easy to maintain

    reply
    0
  • Cancelreply