I'm getting into Angular 2 and webpack and I'm a little confused about how to reference images using file-loader. As far as I can tell, that you cannot directly put a require()
in your html like this:
<img src="require('./abc.png')">
The only way I was able to get this to work was to create a class member and reference it the html.
my.component.ts:
@Component({
selector: 'my-comp',
template: require('./comp.template.html')
})
export class LoginComponent {
private myImg: string = require('./abc.png');
}
html:
<img [src]="myImg">
Is this how you're expected to use file-loader with images?