Inadequate misunderstanding of the file structure

So, I have an application folder in which both my component and its basic template are stored. My question is the line in the component where I indicate the location of my template in @Component decorator, for example.

@Component({
    selector: "add-site-view",
    templateUrl:"app/add-site.template.html"
})

why do I need to explicitly specify "app / template.html" and not use "./" instead of "app /"?

+4
source share
1 answer

@ComponentURL-address ( templateUrland styleUrls) are permitted with respect to index.html, and not a file .ts. That is why you must specify the full path (starting with index.html).

What you can do is use the official one angular-cliat https://github.com/angular/angular-cli

Webpack @Component URL- .ts, , .

+1

Source: https://habr.com/ru/post/1656665/


All Articles