Skip to content

Commit

Permalink
feat: 🎸 support context in components as injection token
Browse files Browse the repository at this point in the history
Inject passed context to components as injection token, Replace
component factory usages with new API
  • Loading branch information
shaharkazaz committed Jan 22, 2023
1 parent ff8ec48 commit 22b8ae0
Show file tree
Hide file tree
Showing 8 changed files with 1,249 additions and 622 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ You can also pass a `context` or an [`injector`](https://angular.io/api/core/Inj
<ng-template #tpl let-title><b>{{ title }}</b></ng-template>

<ng-container
*dynamicView="tpl;
*dynamicView="tpl || component;
context: { $implicit: 'my title' }">
</ng-container>
```

If you pass `context` to a component and the value can be accessed via the `injectViewContext` function.

## `Teleporting`

Teleporting means rendering a view at a different location from its declaration. There are two cases it might be helpful:
Expand Down Expand Up @@ -221,12 +223,15 @@ class ChartDirective{
createComponent({
component: Type<C>;
injector: Injector;
resolver: ComponentFactoryResolver;
environmentInjector: EnvironmentInjector;
context: Record<string, any>;
vcr: ViewContainerRef | undefined;
appRef: ApplicationRef | undefined;
})
```

If you pass `context` to a component and the value can be accessed via the `injectViewContext` function.

### `createTemplate`
The `createTemplate` method takes a `TemplateRef`, and returns an instance of `ViewRef`.

Expand Down
Loading

0 comments on commit 22b8ae0

Please sign in to comment.