我从https://github.com/ng-select/ng-select/issues/786#issuecomment-418655803实现了以下指令。但是我不能把elementdirective指令指向style。
对于一个简单的属性,您可以像w3s中的以下示例那样实现目标
input[type=text] {
width: 100px;
-webkit-transition: width .35s ease-in-out;
transition: width .35s ease-in-out;
}
input[type=text]:focus {
width: 250px;
}Search: <input type="text" name="search">
但是如何对准方括号换行属性呢?示例:
test[di=true] {
color: red;
}<test [di]="true">test</test>
任何想法都是值得欣赏的。
发布于 2019-09-04 16:15:10
我觉得你不能这么做。您应该改用ngClass:
<test [ngClass]="{'tested-class': true}">test</test>
test.tested-class {
color: red;
}发布于 2019-09-04 16:26:36
有两种方法可以添加、删除类,甚至更改类。
<a[ngClass]="{'tested-class': condition }">testing</a>
Or
<a[ngClass]="[condition? 'tested-class-a': 'tested-class-b any-other']">testing</a>https://stackoverflow.com/questions/57784078
复制相似问题