如何在不使用 [(ngModel)] 的情况下以编程方式添加筹码

How to programmatically add chips, without using [(ngModel)]

在我开发的应用程序中,我们有 tag-input 但没有 ngModel,所以项目只是使用鼠标从客户端扔进里面。我希望能够清除筹码并从另一个按钮触发的代码中以编程方式插入我自己的筹码。这该怎么做? tag-input 的模板代码是这样的:

<tag-input [formControlName]="'chips'"
           [inputText]="inputText"
           [editable]="true"
           [identifyBy]="'value'"
           [displayBy]="'display'"
           [allowDupes]="true"
           [theme]="'bootstrap'"
           [addOnBlur]="true"
           [clearOnBlur]="true"
           [addOnPaste]="true"
           [onlyFromAutocomplete]="false"
           [dragZone]="'zone1'"
           [onAdding]="transform"
           [pasteSplitPattern]="splitpattern6"
           [separatorKeyCodes]="[32]"
           [ngClass]="{
             'is-invalid': submitted && chips.invalid,
             missing_parameters: checkIfKeyDocumentApplied()
           }"
           [errorMessages]="errorMessages"
           [validators]="validators"
           [placeholder]="placeholder"
           [secondaryPlaceholder]="secondaryPlaceholder"
           (onSelect)="onSelect($event)"
           (onAdd)="onAdd($event)"
           (onFocus)="toggleQueryFocusStyle(true)"
           (onBlur)="toggleQueryFocusStyle(false)">
           <tag-input-dropdown [showDropdownIfEmpty]="false"
             [autocompleteObservable]="requestAutocompleteItemsFake">
           </tag-input-dropdown>
</tag-input>

我相信您需要支持以编程方式添加或删除表单控件的 FormArray。