我有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>
Run Code Online (Sandbox Code Playgroud)
我不想[(ngModel)]
因包裹问题而使用.
我想用[]和()传统方式.
现在,问题是在selectedRadioButtonValue中没有改变值.这是什么问题?
export class EmployeeComponent {
selectedRadioButtonValue: string = "All";
}
Run Code Online (Sandbox Code Playgroud)