7

I would like to be able to boot multiple app root component into my index.html page. This was initially possible on angular 2 beta 0 - 15, but starting in beta 16, it is not working anymore. Please refer to this code http://plnkr.co/edit/A7fyFUST9IdP1FriauXk?p=preview

please see plunker link above for the code

Hope somebody can modify the code to be able to work on angular 2 beta 17.

Thanks in advance.

CaringDev
  • 8,391
  • 1
  • 24
  • 43
marvs
  • 177
  • 1
  • 9

2 Answers2

5

Just list all the components in bootstrap (and declarations)

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App, ModalComponent, CompComponent],
  providers: [SharedService],
  entryComponents: [CompComponent],
  bootstrap: [ App, ModalComponent ]
})
export class AppModule{}

See also How to dynamically create bootstrap modals as Angular2 components? for a full example.

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
3

http://plnkr.co/edit/APFwcpOGsMlOMVdGCkCI

It got much easier with newer versions:

bootstrap(Comp1);
bootstrap(Comp2);

Also here is a more advanced example of how to implement communication between applications: http://plnkr.co/edit/aZqdJe3OZ8K2odHioWkB

pajics
  • 2,938
  • 3
  • 23
  • 27