【问题标题】:bootstrap alert box in angular -emptyangular -empty 中的引导警报框
【发布时间】:2018-11-11 06:33:31
【问题描述】:

我使用引导提示框来显示成功消息。提交带有消息的警报框后显示完美,但问题是,在提交空警报框之前存在。谢谢。这是代码

$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 />

这是图片,提交前的样子

【问题讨论】:

    标签: html angularjs twitter-bootstrap


    【解决方案1】:

    警告框永远不会隐藏,因为您在回调中定义了变量message,您应该在控制器的开头定义它。

     $scope.message = '';
    

    【讨论】:

      【解决方案2】:

      首先在$http 块之外声明$scope.message;

       $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";
      
          });
      
      };
      

      【讨论】:

      • 没问题 :) @Arter
      猜你喜欢
      • 2018-04-09
      • 2015-04-20
      • 1970-01-01
      • 2022-11-30
      • 2017-01-22
      • 1970-01-01
      • 2022-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多