Will Lopez
Will Lopez

Reputation: 2119

ng-model binding not updating

I have some models being updated from a look-up. It is the 1st line that's not updating (but the other models are updated correctly). I tried wrapping it in an $apply but that made matters worse:

  function mapRequestorToForm() {
    //PrimaryCtyhocnOrInnCode binding not updating
    //$scope.$apply(function() {
        dmpe.form.PrimaryCtyhocnOrInnCode = dmpe.requestor.primaryInnCode;
        dmpe.form.hotelName = dmpe.requestor.hotelName;
        dmpe.form.requestor = dmpe.requestor;
    //});
} 

Here's the input element. Funny thing, the pre element is displaying the correct value.

 <label for="primaryCtyhocn">Primary Inn Code/ CTYHOCN</label>
 <input type="text" id="primaryCtyhocn" name="primaryCtyhocn" ng-model="dmpe.form.PrimaryCtyhocnOrInnCode"
     class="form-control required disabled-bg" disabled
     placeholder="Primary Inn Code/ Ctyhocn"
     ng-minlength="5" ng-maxlength="7"  required  />

<pre>PrimaryCtyhocnOrInnCode: {{dmpe.form.PrimaryCtyhocnOrInnCode}}</pre>

this one is updated correctly (line 2 of the map method, using the same source object with similar disabled attributes:

  <div class="col-md-4">
       <label for="hotelName">Hotel Name</label>
       <input type="text" id="hotelName" name="hotelName" ng-model="dmpe.form.hotelName"
          class="form-control required disabled-bg" disabled
          placeholder="Hotel Name required" required />
  </div>

Upvotes: 1

Views: 63

Answers (1)

Will Lopez
Will Lopez

Reputation: 2119

In case someone else runs into this and their brain is failing them as mine did. It was an issue with the incoming data, it failed the max length constraint. Thanks to Michael Perrenoud!

Upvotes: 1

Related Questions