I have a question about entering empty values in an input field and highlighting its boundary. I added a new class 'warning' for this purpose and created the following code.
HTML:
`<body ng-app="TestPage">
<form ng-controller="TestForm">
<input ng-model="testinput" class="form-input" ng-class="testclass" type="text"/>
<button ng-click="submitButton()">Click</button>
</form>
</body>`
JavaScript:
`angular.module('TestPage',[])
.controller('TestForm', function($scope, $animate) {
$scope.submitButton = function() {
if (($scope.testinput == undefined) || ($scope.testinput == "")) {
$animate.addClass($scope.testclass, "warning");
}
};
});`
However, the addClass
function does not seem to work as expected. What could be the issue here?