Differences of using Component template vs templateUrl

前端 未结 6 1232
一整个雨季
一整个雨季 2020-12-14 08:22

Angular 2 allows to write multi-line templates by using ` characters to enquote them. It is also possible to put multi-line template into .html file and referen

6条回答
  •  佛祖请我去吃肉
    2020-12-14 09:03

    One of the drawbacks of putting your template HTML into separate file might happen if you're developing Angular2+ library that supposed to be used in other projects.

    In this case the consumers of your library might not be able to perform JIT compilation successfully unless they use template loaders like angular2-template-loader or angular2-rollup or any other depending on the bundler that should be properly configured that sometimes might be tricky.

    To avoid this drawback and still have templates in separate files (which i think is quite convenient) the library developer might end up inlining templates automatically using Gulp plugin like gulp-inline-ng2-template or any other. But this would mean additional level of complexity while building ES2015 version of the library.

提交回复
热议问题