angular-directive - 在另一个指令中使用指令
问题描述
如何在另一个指令定义中插入指令规则?我已经定义了这个指令:
@Directive({
selector: "[appCardBody]"
})
export class CardBodyDirective {
constructor(el: ElementRef) {
el.nativeElement.style.width = "95%";
el.nativeElement.style.marginTop = "20px";
}
}
我以这种方式使用这个指令:
<div
appCardBody
fxLayout="row"
fxLayoutAlign="space-between center"
fxLayout.lt-md="column"></div>
如何在我的 appCardBody 指令中直接包含 fx* 属性(来自 angular flex-layout 指令)?
我已经尝试过强制这样的元素:
@Directive({
selector: "[appCardBody]"
})
export class CardBodyDirective {
constructor(el: ElementRef) {
el.nativeElement.style.width = "95%";
el.nativeElement.style.marginTop = "20px";
el.nativeElement.fxLayout = "row"
// the other proprieties
}
}
但是这样是行不通的。有什么建议吗?
解决方案
推荐阅读
- apache-flink - flink 中的自定义指标组
- javascript - React Firebase 应用程序身份验证服务在生产中不起作用
- python - 使用 CSV 文件和 python 的多图像下载器
- java - 上下文类加载器和在依赖项之一中加载资源的问题
- python - 如何在 Python 中对 GENIA 语料库进行 XML 解析
- php - WordPress 使用工作缩略图重命名附件文件
- graphql - 主键与 Amplify Schema 文件的关系
- javascript - React Material-UI Autocomplete:如何在更改另一个字段中的值时清除在自动完成字段中选择的多个值(mui 芯片)?
- javascript - Discord bot 不播放音频文件 (node.js)
- javascript - 尝试将表单结果导出到单个字段