Execute code at startup of angular application

前端 未结 3 914
孤独总比滥情好
孤独总比滥情好 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:27

    You can do like this,

    var app = angular.module('myApp',[]);
    
    app.run(function($rootScope) {
        //.....
    });
    

提交回复
热议问题