Angular 2 404 Html Web Package URL

I am using Angular2 version of RC4 and the webpack dev server. I can not successfully download the application. On the browser console, it issues 404 and does not load the AppComponent template file using webpack. This works if I use lite-server

app.component.ts snippet

@Component({
    moduleId:module.id,
    selector: 'body',
    templateUrl: 'app.component.html',
})

webpack.config.js snippet

 module:{
       loaders:[
            {test:/\.ts$/, loader:'ts',   exclude: /node_modules/},
            {test:/\.html$/, loader:'html' },
       ],

    },

Browser_adapter.js error ? 0526: 84Error: Not shown (in promise): Failed to load / app.component.html

+4
source share
2 answers

In case of Angular2 web package

Use a template like this -

  template: require('./app.component.html'),
  styles: [require('./app.component.css')]

instead

  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']

See if that helps.

+2
source

awesome- typescript -loader angular2 -template-loader , .

https://github.com/TheLarkInn/angular2-template-loader

  module: {
    loaders: [
      {
        test: /\.ts$/,
        loaders: ['awesome-typescript-loader', 'angular2-template-loader'],
        exclude: [/\.(spec|e2e)\.ts$/]
      }
    ]
  },
+6

All Articles