templateUrl does not work for me

后端 未结 7 1678
有刺的猬
有刺的猬 2021-01-05 09:07

I use the seed structure as per angular.io get started project. Everything OK so far.

Now I wanted to change the top component to have a view from a separated file a

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 09:50

    Add moduleId: module.id in the @Component decorator. If you don't have that then Angular 2 will be looking for your files at the root level.

    import {Component} from 'angular2/core';
    
    @Component({
      selector: 'my-app',
      moduleId: module.id,
      templateUrl: 'app.component.html'
    })
    
    export class AppComponent { }  
    

    Check this article

提交回复
热议问题