0

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?

1 Answer 1

1

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" />    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.