Execute code at startup of angular application

前端 未结 3 855
孤独总比滥情好
孤独总比滥情好 2021-01-31 13:44

Is there a way I can execute some JavaScript code at start-up of my AngularJS application? I have some common code that I need to make sure runs before any of the app directives

3条回答
  •  逝去的感伤
    2021-01-31 14:29

    You can use the "run" function from the Module API: http://docs.angularjs.org/api/angular.Module

    This code will be executed after injector creation so you should be able to get at the service you are looking to use.

提交回复
热议问题