ngx-teleport
v0.13.12
Published
A portal component to teleport content to another location in angular
Downloads
438
Maintainers
Readme
<!--This can be anwhere in your App-->
<ngx-teleport to="destination"> <stuff>...</stuff></ngx-teleport>
<!--This can be anwhere in your App-->
<ngx-teleport-outlet name="destination"> </ngx-teleport-outlet>
<!--content will be rendered here-->
<stuff>...</stuff>
About The Project
There are many situations where we would want to break the unidirectional top-down rendering of template/components and render DOM outside of a component, anywhere in your app
Here are few use cases:
- You want to render different template in your toolbar or sidebar based on different routes but you want to bind properties and events in the child component
- You want to conditionally show some template in different corners of your application which may not be hierarchically related
Use the NgxTeleport
to get started.
Installation
npm install ngx-teleport
or using yarn
yarn add ngx-teleport
Usage Example
<!--This can be anwhere in your App-->
<ngx-teleport to="destination"> <stuff>...</stuff></ngx-teleport>
<!--This can be anwhere in your App-->
<ngx-teleport-outlet name="destination"> </ngx-teleport-outlet>
<!--content will be rendered here-->
<stuff>...</stuff>
- Just Import
NgxTeleportModule
in the NgModule of which ever components you are usingngx-teleport
andngx-teleport-outlet
in
import { NgxTeleportModule } from 'ngx-teleport';
@NgModule({
//...
imports: [
//..
NgxTeleportModule,
//..
],
})
export class SomeModule {}
For more examples, please refer to the Documentation
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.md
for more information.
Contact
Nivrith - @_Nivrith_ - [email protected]
Project Link: https://github.com/nivrith/ngx-teleport