2
AngularJSにsweetalert2
とngSweetAlert
を使用して問題が発生しました。SweetAlert2を使用してshowLoaderOnConfirmを取得できません
次のコードは正常に実行されますが、エラーは発生しませんが、待機中のアニメーションは表示されません。アラートは消えて、要求が返されたらポップアップして戻ってきます。
$scope.passwordReset = function() {
swal({
title: 'Forgot Password?',
text: 'Enter your email address and your password will be reset and emailed to you.',
input: 'email',
showCancelButton: true,
confirmButtonText: 'Send',
confirmButtonColor: "#DD6B55",
inputPlaceholder: 'Email address',
showLoaderOnConfirm: true
}).then(function(email) {
if(email) {
AccountFactory.resetAccount(email)
.then(function(data) {
swal({
title: 'Success!',
text: 'A verification email has been sent to ' + email,
type: 'success',
confirmButtonText: 'Close',
allowEscapeKey: false
});
}, function(error) {
swal({
title: 'Email not found',
text: 'Sorry, but we could not find an account matching that email address.',
type: 'error',
confirmButtonText: 'Close',
allowEscapeKey: true
});
console.log('Failed to reset password: ', error);
});
}
});
};
私はpreConfirm
機能で再生しようとしましたが、ほとんど違いはありません。アラートが消えていくのではなく、画面上に残りますが、まだアニメーションは残っていません。
どこが間違っていますか?
マイAccountFactory
次の関数を返します。
resetAccount: function(email) {
var deferred = $q.defer();
$http({
url: ApplicationConstants.apiServerPath + 'api/users/reset',
method: 'POST',
data: 'email=' + email,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function(data) {
deferred.resolve(data);
})
.error(function(error) {
deferred.reject(error);
});
return deferred.promise;
}
:
がSweetAlert2ドキュメントの例でも見てみましょう。電子メールが見つからないときに私の工場がエラーを返していることを確認できますが、決して 'function(error){}'に戻ることはないので、警告は画面上に残ります。私は私の工場コードを表示するために私の投稿を更新しました。 – Riples