In the following example, two-way binding for RadioButton is illustrated with DropDownList component. The steps to achieve two-way binding in RadioButton are as follows,
<ejs-radiobutton [label]='payment' [value]="payment" name="payment" [(ngModel)]="value"></ejs-radiobutton>
value
property value like the below code,<ejs-dropdownlist [dataSource]='paymentMethod' [(value)]="value" ></ejs-dropdownlist>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
// To customize RadioButton appearance
template: ` <div class="radioButton-control">
<h4>Select a payment method</h4>
<div class="row" *ngFor='let payment of paymentMethod'>
<ejs-radiobutton [label]='payment' [value]="payment" name="payment" [(ngModel)]="value"></ejs-radiobutton>
</div>
</div>
<div class="dropDownList-control">
<h4>Payment Method</h4>
<ejs-dropdownlist [dataSource]='paymentMethod' [(value)]="value" ></ejs-dropdownlist>
</div>`
})
export class AppComponent {
public paymentMethod: string[] = ['Credit card', 'Debit card', 'Net Banking', 'Other Wallets' ];
public value:string = "Credit card";
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RadioButtonModule } from '@syncfusion/ej2-angular-buttons';
import { DropDownListModule } from '@syncfusion/ej2-angular-dropdowns';
import { AppComponent } from './app.component';
import { enableRipple } from '@syncfusion/ej2-base';
import { FormsModule } from '@angular/forms';
enableRipple(true);
/**
* Module
*/
@NgModule({
imports: [
BrowserModule,
RadioButtonModule,
FormsModule,
DropDownListModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);