我有 2 app.run method.how 在第一种方法中停止,直到承诺得到解决?
I have 2 app.run method.how to halt in first method until promise is resolved?
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)
我需要先完成Usercervice.acl
调用然后运行第二个运行(app运行)方法需要调用这里是代码来自 UserService.acl()
让 acl = () => {
return $http.get(AppConstants.api + /acl/user-resources
)
.then((res) => {
return res.data
})
}
.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)
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)
我需要先完成
Usercervice.acl
调用然后运行第二个运行(app运行)方法需要调用这里是代码来自UserService.acl()
让 acl = () => { return $http.get(AppConstants.api +
/acl/user-resources
) .then((res) => { return res.data })
}
.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)