使用Angular验证表单时: 'ng-show =“userFieldForm.email。$ invalid&& userFieldForm.email。$ touch”' 并使用Angular //code.angularjs.org/1.4.0/angular.js,它运行正常。
但是在使用//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js时。
我做了搜索,但没有找到真正的解决方案......我确定错过了一个信息。
以下是代码的一部分:
<head>
<meta charset="UTF-8">
<title>index</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<%--<script src="//code.angularjs.org/1.4.0/angular.js"></script>--%>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<%--<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-animate.min.js"></script>
<script src="https://code.angularjs.org/1.2.16/angular-touch.min.js"></script>--%>
<script src="js/users.js"></script>
</head>
<body ng-app="passUser" ng-controller="usersCntrl">
<form name="userForm" novalidate>
<div class="form-group" ng-repeat="user in formData.users" ng-class="{ 'has-error': userForm.email.$invalid && userForm.email.$dirty}">
<label> {{ user.name }}'s Email </label>
<input type="text" class="form-control" name="email" ng-model="user.email" required>
<p class="help-block" ng-show="userForm.email.$invalid && userForm.email.$dirty">Valid Email Address Required</p>
</div>
</form>
</body>
user.js:
var passUser = angular.module('passUser', [/*'ngAnimate','ui.router,'ngTouch'*/]);
passUser.controller('usersCntrl',['$scope', function($scope){
var users = [
{
name: 'Chris',
email: ''
},
{
name: 'Holly',
email: ''
}
];
$scope.formData = {};
$scope.formData.users = users;
}]);
任何想法都会?
由于 k.min