Angular ng-message始终显示

时间:2017-11-07 21:40:45

标签: angularjs forms laravel-5

是什么原因?为什么ng-message总是显示? 包括angularjs / 1.2.7 / angular.js.控制台中没有错误。

        <body>
            <form name="myForm">
                <label>
                    Enter your name:
                    <input type="text"
                           name="myName"
                           ng-model="name"
                           ng-minlength="5"
                           ng-maxlength="20"
                           required />
                </label>
            <div ng-messages="myForm.myName.$error" style="color:maroon" role="alert">
                <div ng-message="required">You did not enter a field</div>
                <div ng-message="minlength">Your field is too short</div>
                <div ng-message="maxlength">Your field is too long</div>
            </div>
        </form>

        <script>
            (function () {
                      myForm.myName.$error = {
            }})
        </script>
        </body>

        </html>

0 个答案:

没有答案