【发布时间】:2019-02-14 23:25:00
【问题描述】:
我有一个广播组:
<div class="btn-group">
<div class="btn btn-outline-secondary"
*ngFor="let category of categories">
<input
type="radio"
[value]="category.id"
[(ngModel)]="categoryModel.name">
{{category.name}}
</div>
</div>
ts
import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss'],
})
export class Test {
categories: {};
categoryModel = {name: ''};
constructor(private modalService: NgbModal) {
this.categories = [{
id: 1, name: 'test1',
},
{
id: 2, name: 'test2'
},
{
id: 3, name: 'test3',
},
]
}
当我点击收音机时,我的模型没有更新, {{categoryModel.name}} 还是空的,有什么问题,怎么改?
【问题讨论】:
标签: angular data-binding ngfor angular2-ngmodel