AngularJSを使用してshowLoaderOnConfirm
作業する際に問題が発生しています。sweetalert2
ngSweetAlert
次のコードはエラーなしで正常に実行されますが、待機中のアニメーションは表示されません。アラートは消え、リクエストが返されると再び表示されます。
$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
たが、ほとんど違いはありません。アラートは消えるのではなく、画面に残りますが、アニメーションは表示されません。
どこが間違っていますか?
MyAccountFactory
は次の関数を返します。
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;
}