angular2-component-outlet
v3.0.1
Published
Angular2 Component Outlet
Downloads
39
Readme
angular2-component-outlet
$ npm install --save angular2-component-outlet
Current Angular Version: 2.0.2
Live Demo: Plunker
ComponentOutlet
is a directive to create dynamic component.
Example:
@Component({
selector: 'my-app',
template: `
<div *componentOutlet="template; context: self; selector:'my-component'"></div>
`
})
export class AppComponent {
self = this;
template = `
<div>
<p>Dynamic Component</p>
</div>`;
}
@NgModule({
providers: [
provideComponentOutletModule({
imports: [CommonModule]
})
],
declarations: [ComponentOutlet]
})
class AppModule {}
Result:
<my-app>
<my-component>
<div>
<p>Dynamic Component</p>
</div>
</my-component>
</my-app>
Notes
ComponentOutlet
needsRuntimeCompiler
provided byplatform-browser-dynamic
. You cannot useplatformBrowser
instead ofplatformBrowserDynamic
.- For AoT compilation, you can use
platformBrowserDynamic().bootstrapModuleFactory()
.
- For AoT compilation, you can use