I am attempting to validate a form using Angular to determine its validity.
The form structure is as follows:
<form name="form" novalidate>
<p>
<label>Number: </label>
<input type="number" min="0" max="10" ng-model="test.number" required />
</p>
<p>
<label>Name: </label>
<input type="text" ng-model="test.name" required />
</p>
<button ng-click="sendTest(test)">Submit</button>
</form>
Within the sendTest function, I have the following code:
angular.module('demo', [
]).controller('MainCtrl', function($scope){
$scope.test = {
name: 'das'
};
$scope.sendTest = function(test) {
console.log(form.$valid);
console.log(test.$valid);
}
});
The issue arises when both form.$valid and test.$valid return as undefined. I have tried to troubleshoot using the following resources:
http://www.youtube.com/watch?v=J82OD76QhPo
To view the complete code for this demo, please visit: http://plnkr.co/edit/l0E62KPJu4Z2r15VNjJq