Best practice for using $rootscope in an Angularjs application?

前端 未结 3 1053
情话喂你
情话喂你 2020-12-02 00:51

We have a large Angularjs 1.6 application that has $rootscope scattered throughout the app in over 200 places in filters, services, routes, etc.. so it needs to be refactore

3条回答
  •  甜味超标
    2020-12-02 00:58

    After doing some more work with Angular and more reading I found this basic rule of thumb for using $rootscope that I wanted to add to the other answers:

    Only add properties that are static or constant. Anything else that represents a changing state or a mutable value should have a corresponding directive or controller to handle it.

提交回复
热议问题