我使用bootstrap警告框显示成功消息。提交警告框后,消息显示完美,但问题是,在提交空警报框之前。日Thnx。这是代码
$scope.resetPassword = function () {
var data = {
email: $scope.resetPasswordEmail
};
$http.post(serviceBase + 'aaaaaaaaaaaa', data).then(function (response) {
$scope.successfullyReset = true;
$scope.message = "Email has been send successfully, you will be redicted to login page in 5 seconds.";
startTimer();
}, function (response) {
$scope.successfullyReset = false;
$scope.message = "Failed to send mail. There is no user with requested email";
});
};
和html代码在这里
<div data-ng-hide="message == ''" data-ng-class="(successfullyReset) ? 'alert alert-success' : 'alert alert-danger'">
{{message}}
</div><br />
答案 0 :(得分:3)
警告框永远不会被隐藏,因为您在回调中定义了变量message
,您应该在控制器的开头定义它。
$scope.message = '';
答案 1 :(得分:1)
首先在$scope.message;
块之外声明$http
。
$scope.resetPassword = function () {
var data = {
email: $scope.resetPasswordEmail
};
$scope.message;
$http.post(serviceBase + 'aaaaaaaaaaaa', data).then(function (response) {
$scope.successfullyReset = true;
$scope.message = "Email has been send successfully, you will be redicted to login page in 5 seconds.";
startTimer();
}, function (response) {
$scope.successfullyReset = false;
$scope.message = "Failed to send mail. There is no user with requested email";
});
};