我需要在变量中提供fxLayoutGap值,而不是直接提供数字。下面的代码供您参考:
例如:Fivepix ='5px';
<div fxLayoutGap="5px"></div>
<div fxLayoutGap="fivepix"></div>
像上面一样,我们可以声明它吗?
答案 0 :(得分:1)
是的,这是可能的。
您必须在 component.ts 中初始化一个值:
ngOnInit() {
this.fivepix = "5px"
}
然后在您的 component.html 中使用模板表达式,如下所示:
<div [fxLayoutGap]="fivepix"></div>