How to bind typescript enum to radio-group by ngModel?


#1

like this one

<ion-list radio-group [(ngModel)]="question.validationType"> <ion-list-header>Validation</ion-list-header> <ion-item> <ion-label>Any(No validation)</ion-label> <ion-radio value="0"></ion-radio> </ion-item> <ion-item> <ion-label>Date</ion-label> <ion-radio (click)="testClick()" value="typeValidation.Date"></ion-radio> </ion-item> <ion-item> <ion-label>Number</ion-label> <ion-radio value="typeValidation.Number"></ion-radio> </ion-item> <ion-item> <ion-label>EMail</ion-label> <ion-radio value="typeValidation.EMail"></ion-radio> </ion-item> </ion-list>
I’ve already referred the ValidationType to class property typeValidation

@Page({
templateUrl:‘build/pages/design/oe_question.html’
})
class OpenEndQuestionEdit {
question: OpenEndQuestion;
validatationType:ValidationType;

typeValidation = ValidationType;

constructor(private viewCtrl: ViewController,
public params: NavParams){
this.question = this.params.get(‘question’);
}

testClick(){
console.log("validation type is ",this.validatationType);
}

closeModal(){
this.viewCtrl.dismiss();
}
}

export enum ValidationType{
Any = 0,
EMail,
Number,
Date
}