【发布时间】:2019-09-17 04:21:25
【问题描述】:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div class="form-group">
<label class="col-md-4">What is the capital city of Italy?
</label>
<input type="text" class="form-control" formControlName="first_question" #first_question />
</div>
所以,我想让输入颜色为红色,除非用户输入正确的答案是罗马?有任何想法吗?我试过了,但没有用:
placeholder="Type" [style.color]="Type === 'rome' ? 'red' : 'green'"
【问题讨论】:
-
显示 TS 代码
-
placeholder="Type" [style.red]="Type === 'rome'" [style.green]="Type !== 'rome'" 是一种简单的方法