default export is not declared in imported module

11,223

Solution 1

try this:

import * as tpl from './tpmInfo.tpl.html'

and then use it like this:

template: tpl.template,

Let me know if this works for you.

Solution 2

For Angular2-Meteor projects I had to do like Wassim says, with small changes:

import * as tpl from './tpmInfo.tpl.html'
and then in Component
template: tpl.default

or

import * as templatefrom './tpmInfo.tpl.html';  
template = template.default;

  @Component({
   //smth,      
    template
  })

this is a string, returned by angular2-compilers module

Share:
11,223
6324
Author by

6324

My heart is in the work.

Updated on June 15, 2022

Comments

  • 6324
    6324 almost 2 years

    I am using ES6 in IntelliJ IDEA. Below is a piece of code.

    import controller from './tpmInfo.ctrl.js'
    import template from './tpmInfo.tpl.html' //default export is not declared in imported module
    
    export default angular.module('tmpApp', [])
        .component('tpmInfo', {
            template: template,
            controller: controller,
            bindings: {
                ags: '='
            }
        })
    .name;
    

    The template html is a normal html, but IntelliJ IDEA throws warning "default export is not declared in imported module". Is there any way to make this warning disappear? Thanks.

  • Wassim Chegham
    Wassim Chegham almost 8 years
    BTW, what module loader or bundlers are you using? SystemJs? Webpack?
  • 6324
    6324 almost 8 years
    We are using Webpack.
  • 6324
    6324 almost 8 years
    Hi, can you revert your answer to the previous version? My code is in app.js so I don't have to set up Webpack here. Your previous answer works for me. Thanks! So the solution is: import * as template from './app.tpl.html' and template: template.