javascript - Communication between controller fail on page reload -


i have been using below reference sharing $scope between controllers. use controller1 in xxx.html , controller2 in yyy.html.

this worked fine until 1 thing have happened. when reloaded page, service not read previous controller's $scope. used controller's in single page, case have different pages controller1 , controller2.

can 1 give me solution overcome this?

reference

service:

app.factory('scopes', function ($rootscope) {     var mem = {};      return {         store: function (key, value) {             $rootscope.$emit('scope.stored', key);             mem[key] = value;         },         get: function (key) {             return mem[key];         }     }; }); 

this lead more work here.

1 : first thing if reloading page ( browser reload ) using angular wrong way .

2 : angular should single page application.

3 : here need sharing data after $state change (may be) if using $state routes not reload change pages , urls.

4: in 3rd case need store data in $rootscope or $parent $scope , can use in next or previous controllers.

5: there 3 recommended ways share data controllers services events rootscope

i recommend using service or events if need more let me know.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -