/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Component, Injectable, Injector, NgModule} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; // #docregion SimpleExample @Component({selector: 'hello-world', template: 'Hello World!'}) export class HelloWorld { } @Component({ selector: 'ng-component-outlet-simple-example', template: `` }) export class NgTemplateOutletSimpleExample { // This field is necessary to expose HelloWorld to the template. HelloWorld = HelloWorld; } // #enddocregion // #docregion CompleteExample @Injectable() export class Greeter { suffix = '!'; } @Component({ selector: 'complete-component', template: `Complete: {{ greeter.suffix }}` }) export class CompleteComponent { constructor(public greeter: Greeter) {} } @Component({ selector: 'ng-component-outlet-complete-example', template: ` ` }) export class NgTemplateOutletCompleteExample { // This field is necessary to expose CompleteComponent to the template. CompleteComponent = CompleteComponent; myInjector: Injector; myContent = [[document.createTextNode('Ahoj')], [document.createTextNode('Svet')]]; constructor(injector: Injector) { this.myInjector = Injector.create({providers: [{provide: Greeter, deps: []}], parent: injector}); } } // #enddocregion @Component({ selector: 'example-app', template: `
` }) export class AppComponent { } @NgModule({ imports: [BrowserModule], declarations: [ AppComponent, NgTemplateOutletSimpleExample, NgTemplateOutletCompleteExample, HelloWorld, CompleteComponent ], entryComponents: [HelloWorld, CompleteComponent] }) export class AppModule { }