私の4角型プロジェクトでは、入力フィールドとMatSelectに値を何も設定せずに値を設定する必要があります。htmlフィールドの値を角度4で設定する
私はマット・オプションおよび入力フィールドの値を設定する必要があり、ボタンをクリックするとこれはHTML
<div class="row search-component">
<div class="col-md-5 no-padding-right">
<mat-form-field>
<mat-select placeholder="searchfor" id="selectedFilter" name="propertyList" #selectedFilter>
<mat-option *ngFor="let property of propertyList" [value]="property">
{{property.label}} </mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="col-md-7 no-padding-left">
<mat-form-field>
<input matInput placeholder="search" id="searchfield" name="searchfield" #selectedValue>
<mat-icon class="pointer" matSuffix>search</mat-icon>
</mat-form-field>
</div>
</div>
です。
setField(chipSelected: Filter) {
this.filter = chipSelected;
document.getElementById('searchfield').focus();
document.getElementById('searchfield').value = 'somevalue'; <-- I can't use this instruction
}
私はなぜ、値にアクセスすることはできません。
これは、値を設定する必要がある方法? どうすればアクセスできますか?
tsファイルで?? –
私の答えが更新されました。要素にアクセスする方法があります。 –