onchange - AngularJs ng-change event fire manually -


 <input type="checkbox" value="" ng-model="filterprivatedoccheckbox" ng-click="dl.filterprivatedocument(filterprivatedoccheckbox, $event)">  <input st-search="target" class="input-sm form-control"  ng-model="dl.documenttarget" ng-change="dl.change()" />  function filterprivatedocument(val)  {     if(val)     this.documenttarget = 'private'; } 

when clicked on checkbox set value text box, saw ng-change event doesn't fired. why?

and when type value in text box observe ng-change event gets fired.

any fix problem?

according the docs:

the ngchange expression evaluated when change in input value causes new value committed model.

it not evaluated:

  • if value returned $parsers transformation pipeline has not changed
  • if input has continued invalid since model stay null
  • if model changed programmatically , not change input value

so not triggered when changed javascript (/angular).

what can do, trigger change function yourself:

function filterprivatedocument(val) {     if(val) {         this.documenttarget = 'private';         this.change();     } } 

see this jsfiddle


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -