Reputation: 199
Is there any way I can do this? I have a form with like 5 inputs, but I want one of them, not to be affected by ngDirty or ngPrestine or any of that, is there anyway I can do this? If you need any more information, please tell me.
Some HTML for context:
<input id="name" ng-model="device.Name" type="text" class="form-control">
<input id="description" ng-model="img.Description" type="text" class="form-control" />
</form>
And CSS which was done by an outsider:
input.ng-dirty
{
&.ng-invalid
{
border: 1px solid $error;
background-color: transparentize($error, 0.95);
}
&.ng-valid
{
border: 1px solid $success;
background-color: transparentize($success, 0.95);
}
}
input.ng-pristine
{
&.ng-invalid
{
border: 1px solid $required;
background-color: transparentize($required, 0.95);
}
}
Now basicly, this says that any input element when is on dirty or prestige state as those colors, how could I ignore that for a single field? Let's say for the 'name' field?
Upvotes: 0
Views: 876
Reputation: 3056
You can achieve that by adding a css class that disables styling on input fields that use it.
The :not()
CSS pseudo-class is perfect for this use.
In CSS
...
input.ng-pristine:not(.no-change) {
...
}
...
The styling will only apply on elements that doesn't have the class no-change
.
In HTML
<input id="name" ng-model="device.Name" type="text" class="form-control no-change">
<input id="description" ng-model="img.Description" type="text" class="form-control" />
Upvotes: 1