代码挂在.subscribe(行
this.generateSeizeRefNo().then(
resolve => {
this.submitBackend(environment.basePrivateUrl + environment.backendRequisition + '/backend/add', 'DRAFT');
});
}
submitBackend(url, body, action){
// return new Promise((resolve) => {
this.http.post(url, body, MediaType.APPLICATION_JSON_VALUE)
.map((res) => res.json())
.subscribe(
(data) => {
console.log(data);
}
}
// resolve(null);
},
(error) => {
console.log(error);
});
// });
}
generateSeizeRefNo():Promise<any> {
return new Promise((resolve) => {
this.http.get(environment.basePrivateUrl + environment.backendRequisition + '/backend/generateSeizeRefNo')
.retry(3)
.map((res) => res.text())
.subscribe(
(data) => {
if (data) {
this.seizeRefNo = data;
}
resolve(data);
});
});
}
应用程序应依次调用以下方法。仅当generateSeizeRefNo返回值时,才启动Submitbackend方法 1. generateSeizeRefNo 2. SubmitBackend