Angular JS - Make service globally accessible from controllers and view

前端 未结 3 669
青春惊慌失措
青春惊慌失措 2020-12-02 11:39

Let\'s say we have the following service:

myApp.factory(\'FooService\', function () { ...

Then, from a controller, I would say:

         


        
3条回答
  •  攒了一身酷
    2020-12-02 11:57

    As far as accessing the service directly in the view, that seems exceedingly un-angular. Binding it to a scope variable in the controller seems like a better solution than using the service directly in the UI to help maintain separation of duties.

提交回复
热议问题