因为项目中各个router的controller中有很多重复的$scope.getName方法声明,想像下面描述一样把这些公共的部分放在路由外的controller里面。
<p ng-controller="parentController">
<p ui-view></p>
</p>
假设parentController中有一个方法叫$scope.getName;
而路由中配置的有个childController,此时在childController直接运行$scope.getName(person.name),是否会影响页面性能。
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