I am new to angularjs.
I have 2 buttons on my form and one is Save and other is Test Connection button.
<td align="left" colspan="0" >
<input class="form-control" title="Specifies the IP address of the SIP trunk ethernet connection." placeholder="xxx.xxx.xxx.xxx"
style="display: inline-block;display:block;white-space: nowrap;overflow: hidden;" type="text"
name="pabxipaddress" id="pabxipaddress" ng-model="userSetup.pabxipaddress" required ng-pattern='patternPresent' >
</td>
<td>
<span class="error" ng-show="(testIPOfficeFlag || submitted) && userSetupForm.pabxipaddress.$error.required">
<label style="color: red;">Required!</label>
</span>
<span class="error" ng-show='(testIPOfficeFlag || submitted) && userSetupForm.pabxipaddress.$error.pattern'>
<label style="color: red;">Invalid IP Address!</label>
</span>
</td>
Now in my JS file when I do like,
$scope.userSetup.pabxipaddress.$valid for some dynamic testing it gives me
TypeError: Cannot read property '$valid' of undefined
when I alert like $scope.userSetup.pabxipaddress it displays the data correctly.
How to check whether individual field is correct and passed all constraints attached to it.
$scope.myform.pabxipaddress.$valid$scope.userSetupForminstead of$scope.userSetupFormngPattern??