Materializecss multiple select Angular 2 中没有触发变化
Materializecss multiple select no firing change in Angular 2
使用 materializecss
"multiple select" 似乎没有触发 change
。如何在 select 更改时绑定方法。
以下代码不会触发更改。
HTML
<select id="booger" multiple>
<option value="1">{{articleIdLabel}}</option>
<option value="2">{{articlePubDateLabel}}</option>
<option value="3">{{articleTitleLabel}}</option>
<option value="4">{{articleViewDateLabel}}</option>
</select>
Component
ngAfterViewInit() {
$("#booger").material_select();
}
change() {
console.log("change");
}
我能够通过对我的代码进行以下更改来解决此问题:
Component
ngAfterViewInit() {
$("#booger").material_select(this.change.bind(this));
}
change() {
console.log("change");
}
使用此代码。它对我有用
<div class="input-field col s12">
<select formControlName="status" [(ngModel)]="selectedStatus" materialize="material_select">
<option [ngValue]="" disabled>Select</option>
<option [ngValue]="1">Enable</option>
<option [ngValue]="0">Disable</option>
</select>
<label>Status</label>
</div>
使用 materializecss
"multiple select" 似乎没有触发 change
。如何在 select 更改时绑定方法。
以下代码不会触发更改。
HTML
<select id="booger" multiple>
<option value="1">{{articleIdLabel}}</option>
<option value="2">{{articlePubDateLabel}}</option>
<option value="3">{{articleTitleLabel}}</option>
<option value="4">{{articleViewDateLabel}}</option>
</select>
Component
ngAfterViewInit() {
$("#booger").material_select();
}
change() {
console.log("change");
}
我能够通过对我的代码进行以下更改来解决此问题:
Component
ngAfterViewInit() {
$("#booger").material_select(this.change.bind(this));
}
change() {
console.log("change");
}
使用此代码。它对我有用
<div class="input-field col s12">
<select formControlName="status" [(ngModel)]="selectedStatus" materialize="material_select">
<option [ngValue]="" disabled>Select</option>
<option [ngValue]="1">Enable</option>
<option [ngValue]="0">Disable</option>
</select>
<label>Status</label>
</div>