Webpack: using require for ng-include

前端 未结 4 996

I\'m new to webpack and right now I\'m using it for the first time in one of my angular projects.

I want to use the require function in my html file in order to requ

4条回答
  •  心在旅途
    2020-12-14 16:33

    Another approach would be to transform my-template.html into a angular component: Assuming you use html-loader to load your HTML files (loaders: {test: /\.html/, loader: 'html'}), define a component myTemplate in your module JavaScript file:

    import myTemplate from './my-template.html';
    angular.module(...)
      .component('myTemplate', {template: myTemplate})
    

    Afterwards use it:

    
    

提交回复
热议问题