component code


export class MyInfoComponent{
    myInfoForm : ControlGroup;
    userProfile:UserProfile;
    constructor(fb:FormBuilder,private _validationService : ValidationService){
        this.userProfile = new UserProfile();
        this.myInfoForm = fb.group({
            'phone' : 
[this.userProfile.phone,Validators.compose([Validators.required, 
ValidationService.passwordValidator])],
            'gender' : 
[this.userProfile.gender,Validators.compose([Validators.required, 
ValidationService.passwordValidator])]
        });
        // this.myInfoForm.changes.forEach(() => 
this.myInfoForm.writeTo(this.userProfile));
    }

    onSubmit(value: string): void {
        console.log('you submitted value: ', this.userProfile);
    }
}


On Friday, 15 April 2016 14:12:01 UTC-7, 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.

Reply via email to