Various dependent files are introduced into the index.html
Angular JS management starts at Ng-app
1Angular.module (' App ', [' '])2. Run (function($rootScope,...) {3 4 //make some basic settings at the root scope5$rootScope. ENV =ENV;6$rootScope. VERSION =VERSION;7 8 //listen for the start of the routing change and do some action with the callback function9$rootScope. $on (' $stateChangeStart ',function(event, ToState, Tostateparams) {Ten One //Save the route that will be accessed in the root scope for subsequent access by the program A$rootScope. tostate =tostate; -$rootScope. Tostateparams =Tostateparams; - the //some permission decisions can be made here - - //If internationalization is required, you can update the current user's language options here - + }); - + //When routing changes are complete, do what you need to do A$rootScope. $on (' $stateChangeSuccess ',function(event, ToState, Toparams, FromState, fromparams) { at - - //Here you can save the previous route to the root scope, or depending on the requirements - //does not save the route to the login page or the registration page. - - //The values of some page header fields are also updated here, which can be saved in the route and obtained when the event is triggered. in - to }); + - //Here you can write some common methods to use in a child scope the //For example, set a method to return to the home page *$rootScope. GoHome =function(){ $ //Back to HomePanax Notoginseng$state. Go (' Home '); - } the + A the }) +. config (function($stateProvider, $httpProvider, $urlRouterProvider, XXX) { - //sets the access/status route if stateless access is enabled. $$urlRouterProvider. Otherwise ('/'); $ //to configure some common routes - $stateProvider. State (XXX). State (XXX); - the //inject some HTTP requests, for example, by adding permission authentication before sending a message , - //when receiving the message, do some special data extraction. or broadcast an exception event when 400 requests are receivedWuyi$httpProvider. Interceptors.push (' XXX ')); the - //to do some other modular configuration Wu})
0003-Program Flow 1