Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Global variables in AngularJS

Asked by Andrew Jenkins Apr 10, 2021 1.4K views 1 answer
Share

About this question

 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 control things such as the navigation bar and restricts access to parts of the site depending on the type of user, so it is important that it holds its value. The problem with it is that the controller that initialises it, gets called again by angular somehow and then resets the variable back to its initial value.

I assume this is not the correct way of declaring and initialising global variables, well it is not really global, so my question is what is the correct way and is there any good examples around that work with the current version of angular?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.