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);
}
11 回答1.3k 阅读
3 回答968 阅读✓ 已解决
2 回答963 阅读✓ 已解决
3 回答949 阅读✓ 已解决
2 回答646 阅读
3 回答993 阅读
3 回答972 阅读
app.html
app.component.ts