我想要一个布尔变量,该变量取决于单选按钮的mgModel(枚举)值。 查看我的代码:
枚举:
export enum advancedSearchMap_SigningTools
{
none,
radius1,
radius2,
radius3,
radius4
}
html
<div class="markerFiled BtnChangeMark">
<label>
<input type="radio" name="m1" value="localAdvancedSearchMap_SigningTools.radius1" [(ngModel)]="selectedAdvancedSearchMap_SigningTools" >
<span>...</span>
</label>
</div>
<div class="markerFiled BtnChangeSearch">
<label>
<input type="radio" name="m1" value="localAdvancedSearchMap_SigningTools.radius2" [(ngModel)]="selectedAdvancedSearchMap_SigningTools">
<span>...</span>
</label>
</div>
<div class="markerFiled BtnChangeSearch">
<label>
<input type="radio" name="m1" value="localAdvancedSearchMap_SigningTools.radius3" [(ngModel)]="selectedAdvancedSearchMap_SigningTools">
<span>...</span>
</label>
</div>
,变量为:
selectedAdvancedSearchMap_SigningTools : advancedSearchMap_SigningTools =
advancedSearchMap_SigningTools.none;
isSigningToolSelected值保持为false。我该怎么做才能使其根据单选按钮的值进行更新(我不想向每个单选按钮添加点击事件)
答案 0 :(得分:0)
确定-修复了该问题:我将该变量设置为属性:
get isSigningToolSelected()
{
return this.selectedAdvancedSearchMap_SigningTools !=
advancedSearchMap_SigningTools.none;
}