angular2怎样根据接口获取的值来选中input[radio]和select?
1楼写的挺好的,补充一下,其实不需要用checked属性也是可以的,
<label *ngFor="let t of typeList">
<input type="radio" name="type" [(ngModel)]="type" [value]="t.id">{{t.name}}
</label>
ngOnInit() {
setTimeout(()=> {
this.type = 2;
}, 1000);
}
13 回答13.1k 阅读
8 回答3k 阅读
3 回答1.6k 阅读✓ 已解决
2 回答5.3k 阅读✓ 已解决
5 回答1.6k 阅读
7 回答2.3k 阅读
3 回答2.4k 阅读✓ 已解决
app.html
app.component.ts