angular - How to plugin a Component in a Component other -


i have component a, plugin index.html, , have template is:

<div> content of </div> <component-will-plugin></component-will-plugin> <button (click)="pluginbtoa()">click me plugin b plugin </button> 

and code of function pluginbtoa:

pluginbtoa(){   redirecttob; } 

how plugin b component in component when click button?

thank read question.

you use dynamiccomponentloader , loadintolocation method way:

@component({   selector: 'my-app',   template: `     parent     <div #child></div>     <div (click)="onclick()">add sub component</div>   ` }) export class myapp {   constructor(private dcl: dynamiccomponentloader,               private elementref: elementref) {   }    onclick() {     this.dcl.loadintolocation(childcomponent, this.elementref, 'child');   } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -