I want the input field to initially have the class .form-control-error
. When the user clicks on the field and starts typing, I would like it to change to .form-control-success
.
I attempted the following code but couldn't get it to update. The ng-change is working as expected, so it seems to be an issue with updating the css.
CSS:
// ... more classes
.form-control-error:focus {
border-color: #FF0000;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6);
}
.form-control-success:focus {
border-color: #5cb85c;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6);
}
JS:
$scope.changeEmail = function () {
console.log('change');
$scope.formControlColor = function () {
return 'form-control-success';
};
};
HTML:
<input type="text" id="email" ng-model="email" ng-change="changeEmail()" placeholder="email" ng-class="{'form-control-error': !formControlColor()}" class="form-control input-lg margin-bottom-15">