templateUrl does not work for me

后端 未结 7 1630
有刺的猬
有刺的猬 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:40

    The issue here seems absolute path. The compnent is requiring absolute path to be mentioned. This is my file structure,

    The following is not working,

    @Component({
        selector: 'pm-products',
        templateUrl: 'product-list.component.html',
        styleUrls: ['product-list.component.css']
    })
    

    As of my knowledge, The HTML template Url or the Url for the style-sheet needs to be given in absolute path. I tried the following and working.

    @Component({
        selector: 'pm-products',
        //template: `

    PRODUCT LISTINGS

    ` templateUrl:'app/products/product-list.component.html' })

提交回复
热议问题