ng-control 和带有 angular2 的单选按钮的双向绑定

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

我目前正在尝试 Angular2 (Alpha 27) 的 FormBuilder 和 ControlBindings (ng-control)。我正在尝试将一些 RadioButtons 与 ng-control 绑定,但我无法让它工作。

我的控制器包含以下表单代码:

this.colours = [{text:"red"}, {text:"green"}, {text:"blue"}];
this.myForm = builder.group({
    someText: [""],
    someColour: ["blue"]
});

在我看来,我尝试了以下操作:

<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>

问题似乎是,ng-control 在我的每个单选按钮上设置了 someColor 的预定义值。单击其他 RadioButtons 之一有效,但绑定值不会更改。这样绑定到我的 ng-control 值的标签将永远不会显示另一个值,而不是预定义值 "blue".

希望有人对此有解决方案,使用 ng-control。

P.S.: 我知道我可以将 RadioButton 绑定到我的控制器的 属性 并通过 ClickBinding 更改值,但这不是我正在寻找的解决方案。

随着时间的推移,Angular2 现在有一个 RadioControlValueAccessor,所以现在可以使用了。 甚至还有一个 angular-material2 组件。