@HostBinding与Angular中的变量类 [英] @HostBinding with a variable class in Angular

查看:171
本文介绍了@HostBinding与Angular中的变量类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以在主机上设置一个类:

I have this code which sets a class on the host:

@HostBinding('class.fixed') true;

我想做的是使它成为我可以修改的变量类. 我该怎么办?

What I would like to do is make this a variable class that I can modify. How can I do this?

推荐答案

不能将其设置为变量.

This can't be made variable.

您可以做的是直接绑定到class属性

What you can do instead is to bind to the class property directly

@HostBinding('class') classes = 'class1 class2 class3';

这篇关于@HostBinding与Angular中的变量类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆