What happens when there are two classes, one decorator/ one class two decorators in a file in Angular 2?

前端 未结 2 601
我在风中等你
我在风中等你 2021-01-24 22:47
@Component({
   selector: \'my-cmp\',
   template: \'
Hello World!
\' }) // here component metadata export class MyComponent { }

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-24 23:44

    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 { }

提交回复
热议问题