javascript - How to retain $scope value once we navigate from one page to another in angularjs -


i have 2 controllers in file. whenever navigate 1 page page, scope values empty. here how declare controllers:

var app = angular.module('name',[]);  app.controller('ctrl1',function($scope){});  app.controller('ctrl2',function($scope){}); 

the above code works fine in 1 html, when navigate html, can't access $scope values in controller.

any appreciated.

changing page wholesale forces angular app reload, , why losing scope. obviously, less desirable. needs happen this:

  1. your base page loads (index.html) , app lives on page. not contain content.
  2. your app calls default route , loads html partial page in main ng-view. route should contain controller reference should operate on view.
  3. when need load new information on screen, load partial ng-view via route, along associated controller.

there plenty of examples out there choose show how this. stuff "year of moo" comes mind. pick 1 , go it.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -