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);
}
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
2 回答4.3k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决
4 回答2.5k 阅读✓ 已解决
5 回答3.8k 阅读
app.html
app.component.ts