角材料切屑不允许使用单个空格字符[closed]

问题描述 投票:0回答:1
我需要使用具有自动完成功能的Angular芯片,但我也需要该组件来输入特定值。

它正在工作,但“空白”存在问题。芯片会自动修剪单个空白。

有没有办法禁用它?

angular angular-material removing-whitespace
1个回答
0
投票
当您将其添加到模型中时,我可以添加一个空白芯片:https://stackblitz.com/edit/angular-rqvtya-bjacta?file=src/app/chips-autocomplete-example.ts

HTML

<mat-chip-list #chipList aria-label="Fruit selection"> <mat-chip *ngFor="let fruit of fruits" [selectable]="selectable" [removable]="removable" (removed)="remove(fruit)"> {{fruit}} <mat-icon matChipRemove *ngIf="removable">cancel</mat-icon> </mat-chip> <input placeholder="New fruit..." #fruitInput [formControl]="fruitCtrl" [matAutocomplete]="auto" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur" (matChipInputTokenEnd)="add($event)"> </mat-chip-list>

TS

fruits: string[] = ['Lemon', ' '];

© www.soinside.com 2019 - 2024. All rights reserved.