I have following html file
<mat-menu #appMenu="matMenu" class="mat-menu-panel-max-width-none">
<mat-radio-group #radioGroup>
<div *ngFor="let item of items, let i=index">
<mat-radio-button color="primary"
[value]="item.value"
[checked]="item.selected"
class="mat-menu-item"
(change)="handleSelection(i)">
{{item.name}}
</mat-radio-button>
</div>
</mat-radio-group>
</mat-menu>
And ts file.
import { Component, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'item-selection',
templateUrl: './item-selection.component.html',
})
export class ItemsComponent {
@Input() items: any;
@Output() electionHandler = new EventEmitter();
constructor() { }
handleSelection(id) {
electionHandler.emit({id:id});
}
}
Here are steps my code is doing:
- Select a item from the menu.
- The result is sent to ngrx store.
- new Input values, items, are set to "item.selected=false" by observable selector.
- After this, I still see the item is selected. The intent is to reset all items unselected after each action.
What is wrong?
electionHandler.emit({id:id});here,idis property and anotheridis variable passed in function.