【发布时间】:2017-01-04 05:02:27
【问题描述】:
我必须根据支持的响应显示我的广播组。 下面的 html 代码在我的侧边菜单中
这是我的代码:
<ion-list radio-group [(ngModel)]="selectedLanguage" class="list-space">
<ion-item *ngFor="let language of languageArray; let val = index" class="radio" >
<ion-label menuClose>{{language.local}}</ion-label>
<ion-radio item-left checked={{languageChoosen}} [value]="language" menuClose (click)="doSomething(language)"></ion-radio>
</ion-item>
</ion-list>
如您所见,我给出的 checked={{languageChoosen}} 是来自 .ts 文件的变量。
如果用户更改任何内容,我可以在我的应用程序第一次打开时显示选定的单选选项,然后我将无法显示选定的单选选项。
更新
doSomething(event){
console.log("invoking dosomething fun");
console.log("checking event params "+event);
let languageObj
if(event){
languageObj = {
lang_id: event.lang_id
}
console.log("cheking languageObj " + JSON.stringify(languageObj));
// this.holders.presentLoadingCustom();
this.rest.post('/language',languageObj)
.subscribe((result)=>{;
// this.holders.dissmissLoadingCustom()
console.log("checking data of success " +JSON.stringify(result));
if(result.status == '1'){
this.logger.debug("checking "+this.selectedLanguage);
this.selectedLanguage = '';
this.toggleLanguages();
for(var i = 0; i < this.languageArray.length; i++){
if(languageObj.lang_id == this.languageArray[i].lang_id){
this.languageChoosen = this.languageArray[i].local;
}
}
this.checkLanguageReq();
}
else{
console.log("error");
}
});
}
else{
console.log("error of languages automatic call");
}
}
【问题讨论】:
-
您的更改是否也将 languageChoosen 更改为 false?
-
我认为问题在于您正在尝试将 html 属性绑定到表达式。应该是:[选中] = "languageChoosen"
-
@Bhetzie 所以我必须为我的
checked =" "指出什么@ -
@Bills 是的,我第二次弄错了,我的侧边菜单中有这种和平的代码
-
请出示您的ts码
标签: angular ionic2 radio-group checked