angular - 2 @HostBinding Angular 中的 1 个成员
问题描述
使用我的组件时,我使用以下默认引导类。它工作得很好(角度6):
@Input()
@HostBinding('class.form-control')
hasFormControl: boolean = true;
但是,我想配置其他 HostBindings 以在相同变量为真时应用,有点像这样:
@Input()
@HostBinding('class.form-control')
hasFormControl: boolean = true;
@HostBinding('class.px-0') this.hasFormControl; // does not compile
如何正确地做到这一点?
解决方案
您可以对同一属性@HostBinding(...)
多次应用以获得所需的结果:
@Input()
@HostBinding('class.form-control')
@HostBinding('class.px-0')
hasFormControl: boolean = true;
推荐阅读
- r - 在 Shiny 中绘制 Kaplan-Meier 图
- powershell - 如何从数组值创建自定义对象
- unity3d - 如何在 Photon Unity 中获取封闭房间的名称?
- python - 从其他模块访问 python namedtuple _fields
- java - 有没有更快的方法将 python numpy 传递给 JPype 中的 java 数组
- java - java中调用另一个方法时触发一个方法(或者没有aop怎么做aop)
- git - 查找没有 PR 的旧分支
- c# - Visual Studio 2017 - 如何从错误消息中删除路径
- c++ - 尝试在矢量上使用擦除功能时“没有匹配的调用功能”
- flutter - analysis_options.yaml 中有多个包含项?