angular - Name for radio group -
i'm trying setup name radio group elements. doesn't work. here component:
@component({ templateurl: "page.html" }) export class fieldcomponent { @input() control: control; @input() value: string; @input() label: string; }
here template:
{{label}} <input type="radio" name="{{label}}" [value]="true" [ngformcontrol]="control" /> <input type="radio" [name]="label" [value]="true" [ngformcontrol]="control" /> <input type="radio" name="abc" [value]="false" [ngformcontrol]="control" />
{{label}}
works ok. did test.
but why name="{{label}}"
, [name]="label"
not works. when hardcode name="abc" can see name in html.
thanks
<input type="radio" [attr.name]="label" [value]="true" [ngformcontrol]="control" />
you can use [attr.attrname]
attribute binding. can more info attribute directives here.
Comments
Post a Comment