html - AngularTS如何将HTML中的输入变量设置为真/假?
问题描述
我有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
为假。当我设置为时它起作用了,falseVariable
我在 .ts 中给出了错误值
falseVariable = false;
但是,如果我将 false 设置为 HTML,它就不起作用
<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';
)
解决方案
allowDupes
是一个布尔变量,不是string
变量。
在第二个代码片段上,您分配string
了变量而不是boolean
变量。
请更换[allowDupes]="'false'"
为[allowDupes]="false"
,它会工作。
推荐阅读
- javascript - 将观察者添加到动态创建的对象
- javascript - 使用 javascript 子字符串更改 innerHTML
- javascript - CSS @页边距不适用于打印预览或物理打印页面
- javascript - 想要在我的 laravel 项目中使用 @section 标签显示画布图像
- node.js - 在 Node.js 中进行 joi 验证后,如何实现 Multer 将图像上传到服务器中?
- java - 迁移到 AndroidX 时的菜单图标大小
- api - 通过 REST API 向 Microsoft Team 发送消息通知
- git - git mergetool cmd 找不到要合并的文件,merge cmd 会
- vba - 如何使用 VBA 显示变音符号?
- javascript - 在 three.js 中加载高质量图像时浏览器崩溃?