ng样式在与的预标记中!重要的是不能工作



<pre ng-style="(errmessage) ? { 'width':'100%', color:'red !important' } : { 'width': '0%' }">{{errmessage}}</em></pre>

如果errormessage不为空,我想使用ng样式将来自指令{{errmessage}}的标记前errormessage的颜色覆盖为红色。

最好使用ng-class而不是ng-style

在css中添加两个类:

.has-error {
  width:100%;
  color: red !important;
}
.no-error {
  width:0%;
}

并在html 中使用

<pre ng-class="errmessage ? 'has-error': 'no-error'">{{errmessage}}</pre>

相关内容

最新更新