$templateCache in Angular 2?

后端 未结 2 644
心在旅途
心在旅途 2021-01-20 23:54

In Angular 1, we use the $templateCache as a way to avoid XHR\'ing down every template from the server as we bootstrap our app. In Angular 2, there doesn\'t appear to be such a

2条回答
  •  半阙折子戏
    2021-01-21 00:34

    I have become accustomed to using template strings in typescript for all my components. I find having the html and view logic all in one TS file very convenient. You could also look into a module loader/bundler like JSPM or WebPack. These great build tools pull in all your templates into your builds using module syntax like below:

    let html = require('./about.html!text');
        @Component({
            selector:"my-about",
            template:html
        })
    

提交回复
热议问题