2017-11-06 26 views
0

フォームの検証が偽であるときにエラーメッセージを表示しようとしています。しかし、メッセージは常に見えます。角型フォームエラーメッセージ

<body ng-app="myApp2" > 
    @include('header') 
    <div ng-controller="ExampleController"> 
     <form name="user-form" method="POST" action="{{route('registrationUser')}}"> 
      {{route('registrationUser')}}"> 
      <div class="form-group"> 
       <div class="form-group"> 
        <label for="firstName" class="col-sm-3 control-label"> 
         Номер телефона 
        </label> 
        <input type="text" ng-pattern="phoneNumbr" name="phone" required> 
        <span class="error" ng-show="myForm.phone.$error.required"> 
         Required! 
        </span> 
        <span class="error" ng-show="myForm.phone.$error.minlength"> 
         Phone no not less that 10 char. 
        </span> 
        <span class="error" ng-show="myForm.phone.$error.maxlength"> 
         Phone no not more than 11 char. 
        </span> 
        <br><span class="error" ng-show="myForm.phone.$error.pattern"> 
         Please match pattern [+91-036-78658 || 91-036-78658] 
        </span> 
       </div> 
       <div class="form-group"> 
        <button ng-click='SaveUser()' name="Регистрация" class="btn btn-primary col-sm-offset-3"> 
         Регисрация 
        </button> 
        {{ csrf_field() }} 
       </div> 
      </div> 
     </form> 
    </div> 
    <script> 
     var app = angular.module('myApp2', []); 
     $scope.positions = ''; 
     app.controller('ExampleController', function($scope) { 
      $scope.positions=Positions; 
      $scope.phoneNumbr = /^\+?\d{2}[- ]?\d{3}[- ]?\d{5}$/; 
     }); 
    </script> 
</body> 
+0

ブラウザコンソールにエラーメッセージはありますか? – Tamali

+0

エラー:[$ controller:ctrlreg] http://errors.angularjs.org/1.6.6/$controller/ctrlreg?p0=ExampleController – Dmitry

+0

質問に追加してください。 – bastelflp

答えて

0

そうのような生命維持にあなたのジャバスクリプトをラップしてみてください。

(function() { code })() 

あなたが途中で何か他のものに標準{{}}からの角度のために補間括弧を変えるになっているはずです。ブレードが同じ構文を使用しているため、問題が発生する可能性があります。

+0

hefeng ..に連絡してください。 – Dmitry

+0

問題がないかもしれませんが、注入する前に$ scopeをなぜ使用していますか? – Tamali