Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Context snippet for Angular #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

None yet

2 participants