我正在使用angular-sweetalert lib在我的应用程序中显示弹出窗口。
function _changeEmailAddress() {
sweet.show({
title: "Change Email Address",
text: "Write your email address:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: 'Enter e mail address'
},
function (inputValue) {
if (inputValue === false) return false; if (inputValue === "") {
sweet.showInputError("You need to write Email address!"); return false
}
at.user.email = inputValue;
var ret = userProfileFactory.updateUserEmailAddress(at.user)
.success(function (data) {
sweet.show("Accepted!", "You wrote: " + inputValue, "success");
at.user.pendingEmailVerification = true;
})
.error(function (err) {
sweet.showInputError("You need to write proper Email address!"); return false
});
});
}
这是视图:
<button class="btn btn-default" ng-click="at.changeEmailAddress()">Change</button>
我面临的问题是,每当我调用 changeEmailAddress 函数时,输入我的输入,然后按 OK。它出现在函数(输入)中,我更改了用户输入的“at.user.email”中的值。
它在后端发生变化,但不会在视图中更新。当我再次单击时,它会更新视图。
正如John Papa Blog在他的博客中提到的那样,我没有使用 $scope、$rootScope 。但是他没有提到调用ngDialog,或者SweetAlert类型的服务时如何解决。
请帮助我如何刷新视图并显示模型中的最新更改。
提前谢谢。