Monitoring specific status fields of a pristine / dirty form

I am trying to create a form that can contain complex "field types". i.e. A group of fields that work together to manipulate the value of a single field.

Each of these field types contains one field that will contain the actual "value" of the field.

Fields containing real data will be attached to them with attributes ng-model=""

. PublishController

will control these fields. If they have fields without ng-model

, it doesn't matter.

Is it possible to make a form, considering yourself dirty / untouched by fields with ng-model

on them?

I don't mind putting a class / attribute on all the fields I want to view, especially if it's an option.

Here's some sample code:

<div ng-controller="PublishController">

  <form name="publishForm" ng-submit="save()">

    <div class="fieldtype">
      <!-- there might be a bunch of form elements in here that a user can manipulate to alter the value that the PublishController is concerned with -->
      <input class="helper-field-1" />
      <input class="helper-field-2" />

      <!-- then the inputs above will perform their own logic, and output their value to this field, which the form *is* concerned with -->
      <input type="hidden" name="myfield" ng-model="data.myfield" />
    </div>

    <div class="fieldtype">...</div>
    <div class="fieldtype">...</div>

    <!-- one of the goals of this is to only show the submit button when the *actual* values have been modified, not the helper fields -->
    <button ng-disabled="publishForm.$pristine">Save</button>

  </form>

</div>

      

Is what I am describing possible?

Thank!

+1


source to share





All Articles