Jim
Jim

Reputation: 16022

update on blur not working in angularjs

I have created a working codepen of this problem here.

I have the following angular markup:
(I have shortened the code snippet here, the full code can be seen in the pen).

My problem is that the model is being updated on every keypress rather than only when the input box is blurred. I am not sure what I have missed?

I actually want the directive(s) to also be triggered on the blur, they are watching the model. I have tried a few combinations of default and blur.

<div ng-app='test' ng-controller='PController'>
  <table>
    <tbody>
      <tr class="top" ng-repeat-start="person in people">
        <td colspan='3'>{{ person.Name }}</td>
      </tr>
      <tr ng-repeat-end ng-repeat="item in person.Items">
        <td>{{ item.AName }}</td>
        <td><input 
          ng-model="item.A" updateana
          ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 1000} }" />
          {{ item.A }}</td>
      </tr>
    </tbody>    
  </table>
</div>

Thanks.

Upvotes: 2

Views: 1644

Answers (1)

mingos
mingos

Reputation: 24502

ngModelOptions is available since version 1.3.0-beta.6. Your plunker uses 1.2.20. If that's the version you're using in your project, there is no ngModelOptions available yet.

Here's an issue with a similar problem: https://github.com/angular/angular.js/issues/7117

Please read the bottom comment by @ggondim (at least "bottom" as of today, July 28th, 2014):

A common confusion when reading docs is the selected version in the dropdown before the breadcrumb. I think it should be selected with the latest stable version and not latest beta.

You probably did the same: assumed the docs by default show the latest stable version, while instead they show the latest beta.

Upvotes: 4

Related Questions