I'm trying to add local image icon with relative path. setting dynamic icon with relative path but getting Module not found: Error: Can't resolve '../../content/images/{{imageList[item.type]}}'. Using require variable image path working fine.
Assets/images
imageA
imageB
imageC
import { Component, OnInit, Inject, OnDestroy } from '@angular/core';
export class PhishingDetailsComponent implements OnInit{
public imageList: any = {'A': 'imageA.png', 'B': 'imageB.png', 'C': 'imageC.png'};
public itemList: any = [{id: 11, type: 'A'}, {id: 21, type: 'B'}, {id: 101, type: 'B'}, {id: 121, type: 'D'}];
public images: any = {
'A': require('../../images/imageA.png'),
'B': require('../../images/imageB.png'),
'C': require('../../images/imageC.png')
};
}
html:
<div class="well">
<div *ngFor="let item of itemList">
<img [src]="images[item.type]" /> // this is working fine.
<img src="../../images/{{imageList[item.type]}}" /> // this is not working.
</div>
</div>
but getting compilation error. plz help me to correct way to use. Thanks.