为什么在我从setTemplate
获得结果之前,我会从getTemplateHtml
获得结果?
在移动到下一个之前,它不应该等待getTemplateHtml
解决吗?
来自我的Angular Controller:
mail.chooseTemplate = async function() {
var res = "";
res = await mail.getTemplateHtml();
res = await mail.setTemplate(res);
};
mail.getTemplateHtml = () => {
return new Promise((resolve, reject) => {
$http({
method: 'GET',
url: "templates/mail" + mail.emailRecord.template + ".html",
headers: { 'Content-Type': 'text/html' }
}).then((response) => {
console.log("getTemplateHtml!!")
resolve(response.data);
return;
})
.catch((error) => {
reject();
return;
})
})};
mail.setTemplate = (templateData) => {
return new Promise((resolve, reject) => {
console.log("setTemplate!!")
mail.showMail = replaceField(templateData);
resolve();
})};