Global variables in AngularJS

前端 未结 12 1824
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 12:05

I have a problem where i\'m initialising a variable on the scope in a controller. Then it gets changed in another controller when a user logs in. This variable is used to co

12条回答
  •  死守一世寂寞
    2020-11-22 12:30

    Try this, you will not force to inject $rootScope in controller.

    app.run(function($rootScope) {
        $rootScope.Currency = 'USD';
    });
    

    You can only use it in run block because config block will not provide you to use service of $rootScope.

提交回复
热议问题