Angular 6 - Change event not trigger for select2 dropdown

Multi tool use
Angular 6 - Change event not trigger for select2 dropdown
The (change) event is working fine with normal select in angular 5. But if I implement select2 plugin, then (change) won't work.
Here is my html file
<div class="form-group">
<label for="stockEntryMaker">Maker</label>
<select formControlName="maker" (change)="makeChanged()" class="form-control select2" id="stockEntryMaker" name="stockEntryMaker" style="width: 100%;">
<option></option>
<option *ngFor="let maker of makerList" [value]="maker.maker">{{maker.maker}}</option>
</select>
</div>
Typescript File:
// Rebuild the model list every time the product type changes.
makeChanged():void {
const maker_name = this.stockForm.get('maker').value;
this.maker = this.stockMasterData.makerModel.filter(m => m.maker == maker_name);
this.modelList=this.maker[0].model;
}
Thanks in advance.
1 Answer
1
You have to use
(change.select2)="makeChanged()"
instead of
(change)="makeChanged()"
I guess you have to. This is my source of information. github.com/select2/select2/issues/3620
– DiabolicWords
2 days ago
Thanks i will check and accept your answer.
– karthik selvaraj
2 days ago
sorry this is not working!
– karthik selvaraj
yesterday
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Do I need any npm package to add for this... I am currently having select2 JQuery plugin.
– karthik selvaraj
2 days ago