1
I need to access from a child component the accordion expander that lies in the parent component, its name is isExpandend
On the child component, when clicking the save button, it should include a new service, and expand the accordion where this new service was added.
In the parent component I already use isExpandend to filter the services and expand the accordion.
This is the HTML Parent code
<mat-accordion class="agregador-pesquisa__accordion mat-accordion" [multi]="isExpanded">
<mat-expansion-panel class="mat-expansion-panel" mat-expanded="true"
</mat-expansion-panel>
</mat-accordion
Component Pai TS
public isExpanded: boolean;
NOTE: I put only one piece of code to facilitate understanding. I just want to know if it is possible to access the isExpanded variable.
Then in case it would be (newItemEvent)="isExpanded($Event)". With this I could manipulate the way I want isExapnded using Output, right ?
– João
In fact the
addItem
must be a method, and it update the propertyisExpanded
.– André Pereira
For example, in the parent component, create the method
updateExpanded(val: string) { this.isExpanded = val }
. And in the template would be(newItemEvent)="updateExpanded($event)
– André Pereira
I get it. Thank you !!
– João