Combating AngularJS executing controller twice -


I understand that AngularJS runs twice through some code, sometimes even more like $ watch Local.get (); // user to save user data locally .get ({id: $ scope.User._id. $ Oid}, function (user) {$ scope.User = new user (user); local.save ($ Scope.User);}); // ...

To put 2 records in my DB, it is executed twice, I am still clearly learning because I have beaten my head for ages against this I am doing

App router resembles specified navigation to MyController :

  $ routeProvider.when ('/', {templateUrl: 'pages / home.html', Controller: MyController});   

But I have also got the code in home.html :

  and 
data-ng-controller = "MyController" Was & gt;

The problem has been solved by removing the data-ng-controller attribute from the double-digested controller. Alternatively, controller: could have been removed from the routing directive.

This problem also appears when using tabbed navigation for example, app.js can contain:

  .state ('tab.reports', {url:' / reports', views: {'tab-reports': templates / tab-reports html', controller: 'reportscटल'}}})   

This report tab can be HTML mail:

  & lt; Ion-View View-Title = "Report" & gt; & Lt; Ion-content ng-controller = "ReportCuttle" & gt;   

This will also result in the controller running twice.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -