We have list like below ( in original implementation productList will come from API )
productList = [{
productId: "104",
productName: "computer"
},
{
productId: "105",
productName: "Sprots"
},
{
productId: "106",
productName: "TV"
}];
we need to display product name as radio buttons in html, something like this.
[] Computer
[] Sports
[] TV
and when we select one radio button it should give selected item in component ( for example if we select TV radio button then, may be something like this ?
this.myForm.controls['productMethods'].valueChanges.subscribe(value => {
var a = value
// how can i get a = { productId: "106",productName: "TV"} **?**
}
for pre selected :-
[] Computer
[x] Sports <== how to make sports as pre-selected on page load also **?**
[] TV
what i have tried is https://stackblitz.com/edit/angular-formarray-example-2-3xq45k but failed to display radio buttons.
Thanks,
*ngForand also addformArrayNamein your template