Angular 2 More than one component on same page

后端 未结 3 1015
生来不讨喜
生来不讨喜 2020-12-14 10:09

I am working from the Angular 2 quick start code on app.component.ts file.

The file looks like this:

import {Component} from \'angular2/core\';

@Com         


        
3条回答
  •  猫巷女王i
    2020-12-14 11:14

    You can't have a component with two component decorators (@Component). You need to create two different classes for this:

    @Component({
        selector: 'app',
        template: `

    Title Here

    ` }) export class AppComponent { } @Component({ selector: 'appTwo', template: `

    Another Title Here

    ` }) export class AppComponent1 { }

    Then you can use the approach from the Gunter's answer...

提交回复
热议问题