markjiang
markjiang

Reputation: 617

Why I get a location string when requiring a html file in webpack?

var uib = $uibModal.open(
  {
    template: require('./create/create.html'),
  }
)

I want get content in create.html and show it in modal,but it shows ./create/create.html,the string of the location in modal.

I've add html loader in webpack.config.js:

    {
      test: /\.html$/,
      loader: 'raw-loader',
    },

Upvotes: 0

Views: 73

Answers (1)

ojus kulkarni
ojus kulkarni

Reputation: 1907

You should use templateUrl

var uib = $uibModal.open({

  templateUrl: require('./create/create.html'),

});

when you want to declare html code in your js that time you can use template
but if you want to call html page like create.html that time you have to call it by templateUrl

also you can write code in template like :-

var uib = $uibModal.open({

  template: '<html><h3> Hie i am in js </h3></html>'

});

Upvotes: 1

Related Questions