我有html:
<tag-input fullWidth id="inputDir" formControlName="inputDir" [modelAsStrings]="true"
[placeholder]="'choice feature'"
[allowDupes]="falseVariable"
[secondaryPlaceholder]="'choice feature'">
<tag-input-dropdown [showDropdownIfEmpty]="true" [autocompleteItems]="inputDirAutoComplete">
</tag-input-dropdown>
</tag-input>我想将allowDupes设置为false。当我设置为falseVariable时,它可以工作,我在.ts中给出了false值
falseVariable = false;
但是,如果我在HTML中设置为false,它将不起作用
<tag-input fullWidth id="inputDir" formControlName="inputDir" [modelAsStrings]="true"
[placeholder]="'choice feature'"
[allowDupes]="'false'"
[secondaryPlaceholder]="'choice feature'">
<tag-input-dropdown [showDropdownIfEmpty]="true" [autocompleteItems]="inputDirAutoComplete">
</tag-input-dropdown>
</tag-input>我错过了什么?
(示例中的库是import { TagInputModule } from 'ngx-chips';)
发布于 2020-10-01 12:05:30
allowDupes是一个布尔变量,而不是string变量。
在第二个代码片段中,您分配了string变量而不是boolean变量。
请将[allowDupes]="'false'"替换为[allowDupes]="false",它将正常工作。
https://stackoverflow.com/questions/64148878
复制相似问题