How to share the $scope variable of one controller with another in AngularJS?

前端 未结 3 1266
情话喂你
情话喂你 2020-12-05 17:51

I have this:

app.controller(\'foo1\', function ($scope) {
  $scope.bar = \'foo\';
});
app.controller(\'foo2\', function ($scope) {
  // want to access the $s         


        
3条回答
  •  春和景丽
    2020-12-05 18:24

    You just can use $emit/$broadcast for translate changes of data from one controller scope to another. Or just store these variables on $rootScope.

提交回复
热议问题