如果值更改,如何在NGFOR输入中更改背景颜色?
<ng-container *ngFor="let obj of List">
<mat-form-field ngDefaultControl class="form-field" appearance="outline">
<input
matInput
type="number"
placeholder="0"
[(ngModel)]="obj.value"
onfocus="this.select()""
/>
</mat-form-field>
</ng-container>
//如果值在其中更改,我正在尝试修改输入元素的背景颜色。
<ng-container *ngFor="let obj of List">
<mat-form-field ngDefaultControl class="form-field" appearance="outline">
<input
matInput
type="number"
placeholder="0"
[(ngModel)]="obj.value"
onfocus="this.select()""
/>
</mat-form-field>
</ng-container>
// I am trying to modify the background color of the input element if the value changed in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是对象的列表数组
,只需使用
[ngstyle]
放置class和
red
是[ngclass]
中的类名称。here is list array of object
and just use
[ngStyle]
to place classand
red
is class name in[ngClass]