You need to create your own ControlValueAccessor <https://angular.io/docs/ts/latest/api/common/ControlValueAccessor-interface.html> or implement it in your component to make `ngModel` work with it. There should be several examples on SO already.
On Friday, April 15, 2016 at 11:12:01 PM UTC+2, yogesh bansal wrote: > > Hi > > i am trying to create a custom radio button using the formbuilder in > angualr 2. Below is the code snippet. I just started to learn angular 2. i > am getting the error in console "angular2.dev.js:23941 EXCEPTION: No value > accessor for '' in [myInfoForm.controls['gender'] in MyInfoComponent@51:80] > " > > <form [ngFormModel]="myInfoForm" (ngSubmit)="onSubmit(myInfoForm.value)"> > > <div class="form-group" > > <label for="gender" class="control-label">Gender</label> > <div class="btn-group" class="control-label" role="group" id="gender" > style="display: flex" name="gender"> > <label class="btn btn-default btn-size" > [ngFormControl]="myInfoForm.controls['gender']" value="Male">Male</label> > <label class="btn btn-default btn-size" > [ngFormControl]="myInfoForm.controls['gender']" value="Female">Female</label> > </div> > </div> > > </form> > > > Any help will be appreciated > > > Thanks > > yogesh > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
