2
Here is some plunker I have created. 왜 작동하지 않는지 나는 이해할 수 없다.
다음은 JS입니다 :단순한 유효성 검사가 작동하지 않습니다.
<body ng-controller="MainCtrl">
<form name="form" novalidate>
<p>
<label>Number: </label>
<input type="text" min="0" max="10" ng-model="age" required />
</p>
<p>
<label>Name: </label>
<input type="text" ng-model="name" required />
</p>
<button ng-click="sendTest(test)">Submit</button>
</form>
</body>
문제는 내가 콘솔 (대신 true
, false
)에 정의되지 않은 얻고 있다는 것입니다 : 여기
angular.module('demo', [
]).controller('MainCtrl', function($scope)
{
$scope.name = "Vlad";
$scope.age = 11;
$scope.sendTest = function()
{
console.log($scope.name.$valid);
console.log($scope.age.$valid);
}
});
는 HTML입니다.
여러 개의 양식이 있다면 어떻게 될까요? 나는 그것을 plunker에서 작동 시키려고 노력할 것이다. – vlio20
다른 이름을 지정하십시오. – ivarni
감사합니다. 범위 모델을 통해 할 수없는 이상한 일을했습니다. – vlio20