Skip to content

Conversation

@raghavkanwal
Copy link
Contributor

@raghavkanwal raghavkanwal commented Jul 29, 2023

Context Composition is a bit tricky with Angular, I've used the in-built ngTemplateOutletContext to perform this. More info here

@samvimes01
Copy link

samvimes01 commented Aug 6, 2023

In terms of React/SolidJS Context is for avoiding props drilling. Regarding Angular, a parent component could provide a service available in all components below in the DOM tree. Template outlet context won't provide a context below the first-tier child
E.g.
Parent Tabs

@Component({
...
template: '<app-tabs><app-tab *ngFor="let tab of tabs" [tab]=tab /></app-tabs>',
providers: [LocalTabsService]
})
export class TabsComponent {...}

Tab:
<div>...<app-subtab /></div>

Subtab component

export class SubtabComponent {
 localTabs = inject(LocalTabsService); // available here without Props (inputs) drill
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants