제 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
}
내가 값에 액세스 할 수없는 이유는 무엇입니까? 어떻게 액세스 할 수 있습니까?
이이 방법을 쓰고있는 더 나은 솔루션 방식으로 입력 ngModel을 사용하는 것입니다 TS 파일에서 ?? –
업데이트 내 대답은 모양을 가지고 그 요소에 액세스 할 수 있습니다 .. –