component-party.dev
component-party.dev copied to clipboard
Added Context snippet for Angular
Context Composition is a bit tricky with Angular, I've used the in-built ngTemplateOutletContext to perform this. More info here
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
}