控制台错误未在ng-show中显示

时间:2015-10-02 08:37:27

标签: ng-show

您好我有一个注册表,其中包含以下代码:

  $scope.signUp = function() {
      if (!$scope.regForm.$invalid) {
       var email = $scope.user.email;
           var password = $scope.user.password;
           if (email && password) {
               auth.$createUser( {email: email, password: password})
                   .then(function() {
                       // do things if success
                       console.log('User creation success');
                       $location.path('/home');
                   }, function(error) {
                       // do things if failure
                       console.log(error);
                       $scope.regError = true;
                       $scope.regErrorMessage = error.message;
                   });
                }
             }
          };

如果regError为true,则显示与控制台显示相同内容的错误消息。

  <button type="button" ng-click="signUp();" ng-disabled="!user.email || !user.password" class="btn btn-lg btn-primary btn-block">Register</button>
  <p style="color:red;" ng-show="regError">{{regErrorMessage}}</p>

我不太明白这里发生了什么,但正常的表单验证以及错误的控制台输出都起作用,但是regErrorMessage从不显示。有谁能看到明显的东西?为什么控制台工作正常但不是ng-show?

1 个答案:

答案 0 :(得分:0)

您应该使用大括号{{regError}}