Angular 加载时在输入字段中计算标签长度
我在输入字段onload中计算标记长度时遇到问题。但现在它只会开火 我提供一个代码和作为您的参考 HTMLAngular 加载时在输入字段中计算标签长度,angular,typescript,Angular,Typescript,我在输入字段onload中计算标记长度时遇到问题。但现在它只会开火 我提供一个代码和作为您的参考 HTML <div [formGroup]="form"> <div class="editor-tag" (click)="focusTagInput()"> <span class="tag-item" *ngFor="let tag of tags"> {{tag}} <span class="remov
<div [formGroup]="form">
<div class="editor-tag" (click)="focusTagInput()">
<span class="tag-item" *ngFor="let tag of tags">
{{tag}}
<span class="remove-tag" (click)="removeTag(tag)">×</span>
</span>
<input
#tagInput type="text"
class="input-tag"
(keyup)="onKeyUp($event)"
(onTagsinput)="eventFire($tag)"
formControlName="tag">
</div>
</div>
希望你们都能帮我解决这个问题你应该使用ViewChildren而不是ViewChildren
@ViewChildren(HtmlInputElement)ViewChildren:QueryList 使用ViewChildren和ViewChild有什么不同?如果html中只有一个元素,则可以使用ViewChild,因为它只提供第一个元素。如果有多个元素,则应使用ViewChildren来获取所有元素
ngOnInit() {
this.eventFire(event);
this.form = this.fb.group({
tag: [undefined],
});
}
eventFire(event){
console.log(event)
}