0

I have Angular2 (2.0.0) with ng-bootstrap on my server side application. All the templates are rendered using php (not angular).

When I any include any ng-bootstrap snippet from server side, it does not work. But if I include them from angular template inside <app-root>...</app-root> then it works.

I basically need to include dropdown, modal, alert... anywhere on the template as direct directive style. How is that possible?

<body>

<h1>Title 1</h1>

<p>This is para...</p>

<app-root></app-root> <!-- any ng-bootstrap directives are accessable inside app-root -->

<!-- I'm not rendered as ng-bootstrap directive, since its not inside app-root -->
<ngb-alert [dismissible]="false">
    <strong>Warning!</strong> Better check yourself, you're not looking too good.
</ngb-alert>


 <!--script tags are included here for angular2-->

</body>
Basit
  • 16,316
  • 31
  • 93
  • 154

1 Answers1

0

If you want an Angular2 component as direct child of <body>, you have to bootstrap it. This means you need an NgModule with that component in bootstrap: [NgbAlert] and then call platform.bootstrapModule(NgbAlertModule). This creates a new Angular2 application on your page for each bootstrapped module.

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