使用带有Angular 2的Web包文件加载器

使用带有Angular 2的Web包文件加载器,angular,webpack,webpack-file-loader,Angular,Webpack,Webpack File Loader,我正在进入Angular 2和webpack,我对如何使用引用图像有点困惑。据我所知,您不能像这样在html中直接放置require(): <img src="require('./abc.png')"> html: 这就是您使用图像文件加载器的方式吗?检查这里: @Component({ selector: 'my-comp', template: require('./comp.template.html') }) export class LoginCom

我正在进入Angular 2和webpack,我对如何使用引用图像有点困惑。据我所知,您不能像这样在html中直接放置
require()

<img src="require('./abc.png')">
html:


这就是您使用图像文件加载器的方式吗?

检查这里:
@Component({
    selector: 'my-comp',
    template: require('./comp.template.html')
})
export class LoginComponent {
    private myImg: string = require('./abc.png');
}
<img [src]="myImg">