任何人都可以帮助我将服务器上的数据绑定到我选择的单选框,这里是我的radioview.component.html
来查看从服务器数据中选择的广播:
<StackLayout>
<Label text="Tipe :" paddingLeft="10" textWrap="true" row="0" col="0"></Label>
<StackLayout *ngFor="let option of radioOptions" class="inline">
<StackLayout orientation="horizontal" verticalAlignment="center" >
<CheckBox #elem [checked]="option.selected" (checkedChange)="elem.checked !== option.selected && changeCheckedRadio(option)" class="checkbox" boxType="circle"></CheckBox>
<StackLayout verticalAlignment="center">
<Label [text]="option.text" textWrap="true" (tap)="changeCheckedRadio(option)"></Label>
</StackLayout>
</StackLayout>
</StackLayout>
</StackLayout>
这是我的 radioview.component.ts
import { Component, OnInit } from '@angular/core';
import { Switch } from "ui/switch";
class RadioOption {
text: string;
selected: boolean = false;
value:string;
constructor(text: string, value: string) {
this.text = text;
this.value = value;
}
}
@Component({
moduleId : module.id,
selector : 'warehouse-detail',
providers : [httpService]
})
export class RadioViewComponent {
valueSelect:string = 2;
constructor(){
this.radioOptions = [
new RadioOption("text one", "1"),
new RadioOption("text two", "2"),
new RadioOption("text three", "3")
];
}
changeCheckedRadio(radioOption: RadioOption): void {
radioOption.selected = !radioOption.selected;
if (!radioOption.selected) {
return;
}
this.radioOptions.forEach(option => {
if (option.text !== radioOption.text) {
option.selected = false;
}
});
}
}
我想在Radioview中选择值,如何绑定数据?
需要帮助