In my Database i save gender, male="yes" In place of true i saved 'yes'. I am getting some other fields including gender to frontend in 'x' array. Now i want to show the gender with checked. I tried but not getting. can someone please help.
html
<div class="radio">
<input type="radio" [value]="gender.male" name="gender" checked="getradio()">Male
<input type="radio" [value]="gender.female" name="gender" checked="getradio()">Female
</div>
TS
getradio(){
let checked=false;
if(this.x[0].gender=='yes'){
checked=true
}else{
alert("not working")
}
}
您的 getradio() 函数应该返回 true 或 false,为了评估这个函数,您应该将 'checked' 放在方括号中: [checked]="getradio()"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.