ecmascript 6 - ng-control and two-way binding on radio buttons with angular2 -


i'm trying formbuilder , controlbindings (ng-control) of angular2 (alpha 27). i'm trying bind radiobuttons ng-control, can't work.

my controller contains following code form:

this.colours = [{text:"red"}, {text:"green"}, {text:"blue"}]; this.myform = builder.group({     sometext: [""],     somecolour: ["blue"] }); 

on view tried following:

<p *ng-for="var colour of colours">     <input id="{{colour.text}}" name="somecolour" type="radio"     ng-control="somecolour"     [checked]="myform.controls.somecolour.value == colour.text">             <label for="{{colour.text}}">{{colour.text}}</label> </p> 

the problem seems be, ng-control sets predefined value of somecolor on every 1 of radio-buttons. click on 1 of other radiobuttons works, bound value not changed. label bound value of ng-control never show value, predefinied value "blue".

hope has solution this, using ng-control.

p.s.: know can bind radiobutton property of controller , change value clickbinding, that's not solution i'm looking for.

as time flew by, angular2 has radiocontrolvalueaccessor, works now. there's angular-material2 component this.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -