nativeelement.value
在我的项目中,由于一些只读错误,必须使用 ElementRef 。只有我的指令
export class DeliveryAcrossDirective {
@Input('key') key: string;
@Input('component') component: string;
constructor(
private store: Store,
private elementRef: ElementRef<HTMLInputElement>
) {
this.key = '';
this.component = '';
}
@HostListener('change') onChange() {
console.log('noticed something');
this.store.dispatch<IAction<IAdjust>>({
type: RDX_DELIVERY_ACROSS_ADJUST,
payload: {
key: this.key,
value: this.elementRef.nativeElement.value
},
component: this.component
})
}
}
没有从我的垫子选择中捕获更改事件
<mat-form-field class="full-width" [@transformRightLeftStateTrigger]="stateDown | async">
<mat-label>
{{ country | async }}
</mat-label>
<mat-select [formControl]="countryFormControl"
appDeliveryAcross
[key]="'iso'"
[component]="'delivery-across'" >
<mat-option *ngFor="let language of (languages | async)" [value]="language.value">
{{ language.country }}
</mat-option>
</mat-select>
</mat-form-field>
而经典输入确实
<mat-form-field class="full-width" [@transformRightLeftStateTrigger]="stateDown | async">
<input matInput
[formControl]="minFormControl"
[errorStateMatcher]="errorStateMatcher"
placeholder="Minimaal"
appDeliveryAcross
[key]="'min'"
[component]="'delivery-across'"
type="number">
</mat-form-field>
有谁知道如何使用指令从 mat select 中捕获更改事件?