I am able to validate my form element 'name'd 'username'.
ng-class="{ 'has-error': form.username.$dirty && form.username.$invalid }"
But I cannot get this info inside a controller. Is this possible?
I want to do something like this:
mycontroller.controller('mycontroller', function ($scope){
$scope.isusernameinvalid = $scope.form.username.$dirty && $scope.form.username.$invalid;
});
And use the isusernameinvalid (true/false) to toggle class
ng-class="{ 'has-error': isusernameinvalid }"
I know "form" is not a $scope variable, and hence inaccessible.
How do i access the validation state/class info over here?