Render Angular component outside the main app

前端 未结 2 1434
挽巷
挽巷 2020-12-19 04:20

I have an angular app, it has a bundle and a piece of HTML that contains a root selector

 

where the app is bootstr

2条回答
  •  时光说笑
    2020-12-19 05:04

    Just add any components you need to the bootstrap array that is passed to NgModule:

    @NgModule({
      declarations: [AppComponent, ContactFormComponent],
      imports: [...],
      providers: [SharedService],
      bootstrap: [AppComponent, ContactFormComponent]
    })
    export class AppModule {}
    

    and now voila this works:

    
      
      ============================================
      
    
    

    Just learned this from the plunker in the answer Günter linked above. very cool. tested with angular 6

提交回复
热议问题