Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.16 KB

README.md

File metadata and controls

58 lines (43 loc) · 1.16 KB

npm version NPM Bundle Size Download

Inyector

Angular service for component injection

Installation

npm install inyector --save

Demo

You can see the demo in https://inyector.netlify.com/

Usage

Import

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { InyectorModule } from 'inyector';

@NgModule({
    imports: [
        BrowserModule,
        InyectorModule.forRoot()
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

Inject component in body

this.inyector.add(TestComponent);

Inject component in an element

this.inyector.add(TestComponent, {
    parent: htmlElement
});

Floating injection

Inject component in a floating docker and attach it to another element

this.inyector.dock(TestComponent, parentHtmlElement, {
    position: 'top'
});