R
R
Roman_Gy2018-02-16 07:56:32
Angular
Roman_Gy, 2018-02-16 07:56:32

How to properly use global variables in SPA?

I have an idea for a small browser-based text quest, I want to make it in angularjs in SPA format.
During the implementation, I ran into such a question - how to use global variables correctly. For example, there are character characteristics that can change throughout the quest.
What is the correct way to use variables for this, so that they can be accessed from any controller with the ability to change them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2018-02-17
@Casufi

https://angular.io/tutorial/toh-pt4
For a small quest, services should be enough, but if you want states, here is
https://github.com/ngrx/store for 2
https://github.com/ngrx /platform for 4+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question