我有一个表,其数据来自 angular 7 中的循环。这里一切正常,但根据我的 json,列中有 "enable":true 和 "enable":false。如果我的值为 true,复选框应该被检查,如果值是假的复选框应该在表中取消选中。这是我的代码如下
应用程序组件.html
<table>
<tr *ngFor="let user of users">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td><input type="checkbox" checked></td>
</tr>
</table>
app.component.ts
import { Component, OnInit } from '@angular/core';
import { CommonserviceService } from './../utilities/services/commonservice.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
getListData: any;
constructor(private commonserviceService: CommonserviceService) { }
ngOnInit() {
}
users = [{"id":1,"name":"test","enable":true},{"id":2,"name":"test","enable":false}];
}
PIPIONE
相关分类