我尝试使用 Angular 指令,它在按钮操作时将角度材料输入插入到 DOM。但是我有问题,没有角材料样式,有人可以帮我吗?
var div = document.getElementById('something');
div.style.position = "absolute";
div.style.left = event.pageX + 'px';
div.style.top = event.pageY + 'px';
var a = ` <mat-form-field class="auto-width mt-3 mr-3" floatLabel="never" style="margin-bottom: -1.25em">
<input matInput [placeholder]="'Search' | translate" [(ngModel)]="filterBox.searchString"
(keyup)="searchTerms.next($event.target.value)" type="text" autocomplete="off">
<i class="fal fa-search" matPrefix></i>
<i class="fal fa-times warn-color" [class.d-none]="!filterBox.searchString" (click)="clearSearch()"
matSuffix></i>
</mat-form-field>
</ul>
this.renderer.setProperty(div, 'innerHTML', a);