0

According to comments in Angular2 and jQuery 'change' events, the following can be used to trigger change event for an input field:

const customEvent = document.createEvent('Event');  
customEvent.initEvent('input', true, true);
$('#input1')[0].dispatchEvent(customEvent);

But this does not seem to work for password input field. How to make it work for password field?

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
user1775616
  • 73
  • 1
  • 5
  • actually I have a general question: how to use jquery to $().val('some value') to set value for input field with angular 2? – user1775616 Apr 01 '18 at 04:01
  • 1
    The way jquery and Angular2 works is different. In Angular2, you can bind the value of an input to Javascript variable. For that, you just need to use ngModel attribute. Learn more about two way binding through ngModel from this site. http://jilles.me/ng-model-in-angular2-two-way-data-binding/ – nirazlatu Apr 01 '18 at 05:12

0 Answers0