Angular directive and Webpack Html-loader

Source: Internet
Author: User

Problem:

Angular's directive supports two ways to specify templates using template and Templateurl

Template method needs to put the HTML content in JS, although there are es6 string can be wrapped, less editor on the HTML of the smart complement is not very uncomfortable

Templateurl is a friendly way for a purely static managed angular project

If the page is returned by the back-end server, the page will not be found using a relative path (which is of course)

So will use $templatecache to put the page content into JS (gulp, such as Ngtemplatecache tools)

You have to introduce additional JS.

Solve:

Webpack's Html-loader the document to the elegant solution.

After configuring Html-loader in Webpack.config.js, simple use of Template:require ("./template.html") solves the:)

Angular directive and Webpack Html-loader

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.