本文介绍了使用ng-class,ng-form和'has-error'验证角度js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好。所有人都可以通知我我错过的一点hello all ..Can any one notify me about the point i am missing<ng-form name="myForm" novalidate ng-app="myApp" ng-controller="appCtrl"> <div class="form-group" ng-class="{'has-error': myForm.name.$invalid && !myForm.name.$pristine}"> <label>Name</label> <input type="text" required ng-model="name" name="name" /> </div> <div class="form-group" ng-class="{'has-error': myForm.age.$invalid}"> <label>Age</label> <input type="text" required ng-model="age" name="age" /> </div> <input type="button" ng-click="click()" value="clcik" class="btn btn-primary" /> </ng-form> 此代码无法正常工作..什么我想要的是当页面加载时,'has-error'应该应用于名称和年龄输入,它们应该用颜色镶边(突出显示字段)。但就我而言,这种情况并没有发生。我不知道我错过了什么。this code is not working properly .. what i want is when the page loads the 'has-error' should be applied on name and age inputs and they should be bordered with color ( highlight the fields). but in my case this is not happening. I dont know what i am missing.angular.module('myApp', []).controller('appCtrl', function ($scope) { $scope.name = ""; $scope.age = ""; $scope.click = function () { if ($scope.myForm.$valid) { alert('our form is amazing'); } }}); 当我写自己的'has-error'css类风格时。整个div变得突出。 我已经包含了bootstrap.min和angular js ..可以任何一个帮助Also when i write my own 'has-error' css class style. the whole div gets higlighted.I have included bootstrap.min and angular js.. can any one help推荐答案 此代码无法正常工作..我想要的是当页面加载'has-error'时应该应用于名称和年龄输入,它们应该用颜色镶边(突出显示字段)。但就我而言,这种情况并没有发生。我不知道我错过了什么。this code is not working properly .. what i want is when the page loads the 'has-error' should be applied on name and age inputs and they should be bordered with color ( highlight the fields). but in my case this is not happening. I dont know what i am missing.angular.module('myApp', []).controller('appCtrl', function ( 这篇关于使用ng-class,ng-form和'has-error'验证角度js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 03:05