@easy-two/ngx-child-injector
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.2 • Public • Published

ChildInjector

This package provides ChildInjectorModule and component for using Angular child injectors in Angular application without lazy loading and RouterModule.

Usage

Install the package and transformer:

npm i --save @easy-two/ngx-child-injector @easy-two/ngx-child-injector-transformer

or

yarn add @easy-two/ngx-child-injector @easy-two/ngx-child-injector-transformer

Import dependency in your code:

import { ChildInjectorModule } from '@easy-two/ngx-child-injector';

Add the code to imports of the parent module:

ChildInjectorModule.forModules([
  AnotherModule
])

And also import ChildInjectorModule and add next code to the imports block of AnotherModule:L

ChildInjectorModule.forChildModule([SomeComponent])

Somewhere in HTML of some component of your parent module you need to add next HTML to render component:

<app-child-injector [component]="WithCustomInjectorComponent" [inputs]="inputs"></app-child-injector>

Note that WithCustomInjectorComponent have to be declared in the component class (it is just a reference to the component class you want to render).

Full example is available in this github repo.

This code is part of article in AngularInDepth.

Readme

Keywords

none

Package Sidebar

Install

npm i @easy-two/ngx-child-injector

Weekly Downloads

2

Version

0.0.1-alpha.2

License

MIT

Unpacked Size

204 kB

Total Files

32

Last publish

Collaborators

  • nickbullock
  • vladsharikov