search

Home  >  Q&A  >  body text

angular.js - Angularjs shares methods from the parent controller to the child controller through routing. Will it seriously affect performance?

Because there are many repeated $scope.getName method declarations in the controllers of each router in the project, I would like to put these common parts in the controller outside the router as described below.

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

Suppose there is a method called $scope.getName in the parentController;
And there is a childController configured in the route. At this time, if $scope.getName(person.name) is run directly in the childController, will it affect the page performance?

我想大声告诉你我想大声告诉你2839 days ago626

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