Angular 2单选按钮2路绑定

时间:2017-11-25 09:01:27

标签: javascript jquery angular

我有3个单选按钮如下:

html的:

<input type="radio" name = "options" value="All" [checked]='selectedRadioButtonValue' (input)='selectedRadioButtonValue=$event.target.value' />
<span class="radioClass">{{"All("+all+")"}}</span>

<input type="radio" name = "options" value="Male" [checked]='selectedRadioButtonValue' (input)='selectedRadioButtonValue=$event.target.value' />
<span class="radioClass">{{"Male("+male+")"}}</span>

<input type="radio" name = "options" value="Female" [checked]='selectedRadioButtonValue' (input)='selectedRadioButtonValue=$event.target.value' />
<span class="radioClass">{{"Female("+female+")"}}</span>

由于包裹问题,我不想使用[(ngModel)]

我想使用[]和()传统方式。

现在,问题是在selectedRadioButtonValue中没有改变值。这是什么问题?

export class EmployeeComponent {

selectedRadioButtonValue: string = "All";

}

0 个答案:

没有答案