javascript - AngularJS controller is executed every time the view is routed -
Every time I change through a link like the following
& lt; Li & gt; & Lt; A href = "# / home" & gt; Home & lt; / A & gt; & Lt; / Li & gt; The controller goes back again to look in the router definition
config (['$ routeProvider', '$ locationProvider', function ($ route provider) , $ LocationProvider) {// $ locationProvider.hashPrefix ('!'); $ RouteProvider.when ('/ Home', {templateUrl: 'partials / home.html', Administrator: 'mainCtrl'}); $ routeProvider.when ('/ Test', {templateUrl: 'partial / test.html', controller: 'testCtrl'}); $ route provider otherwise ({redirectTo: '/ home'});}]); I do not think that this is the default behavior (I did not find any mention in the document), although I can not see what the problem is.
PS
I do not have any ng-controller assigning any DOM element in my templates, because I have seen any other problem where this problem was.
This is a default behavior.
Basically the controller is used to rationalize the function. Therefore, the page connected to the controller should be opened every time. Each time your page is navigated, a new radius will be created.
Comments
Post a Comment