0
angular.module('app', [
        ...   ])

.constant('AppConstants', constants)

.config(appConfig)

.run((UserService, User) => {
    'ngInject';
    console.log('apprun')
    UserService.acl()
        .then((data) => {
            console.log('data')
            User.setACL(data)
            console.log(data)//finsish this first then go to second run call
        })
        .catch((err) => {
            console.log(err);
        })

})
.run(appRun)

.component('app', AppComponent)
  1. 我需要先完成Usercervice.acl调用,然后运行第二个 run(apprun) 方法需要调用这里是代码来自UserService.acl()

    让 acl = () => { return $http.get(AppConstants.api + /acl/user-resources) .then((res) => { return res.data })
    }

4

1 回答 1

0
.constant('AppConstants', constants)

.config(appConfig)

.run((UserService, User) => {
    'ngInject';
    console.log('apprun')
    UserService.acl()
    .then((data) => {
        console.log('data')
        User.setACL(data)
            console.log("done with first run")//finsish this first then go to second run call
            /*here is my second run block i.e. on success of first one*/

            var acl = () => { 
                return $http .get(AppConstants.api + /acl/user-resources).then((res) { 
                    return res.data 
                })
        }
    })
    .catch((err) => {
        console.log(err);
    })

})
.run(appRun)

.component('app', AppComponent)
于 2017-02-14T12:23:55.740 回答