angularjs ui-router - how to build master state which is global across app

前端 未结 3 994
[愿得一人]
[愿得一人] 2020-12-02 05:30


...


  
3条回答
  •  星月不相逢
    2020-12-02 05:44

    It depends how you prefer to approach it.

    All scopes inherit from rootScope so you may place global state there. The NG literature specifically mentions that you should only put global state there, and not functionality. Functionality required across the system belongs in services, and specifically you should not implement services whose sole purpose is to retain state. All the advice seems to be implicitly shared in the context of how it either facilitates or hampers your ability to easily do end to end testing.

提交回复
热议问题