So I have a list of doctors and I want to display for each doctor in the list the corresponding image. The doctors have an ID so I tried to make the path for the image on ng-init but it still does not work. Can someone help me out? Here's the code.My images are stored in the assets/img folder and the corresponding image for every doctor matches the id of the doctor (Example: Doctor 1 with the id 1 has the image "1.jpg" etc. Also, is there any easier way to do this? Thank you!
<li *ngFor="let doctor of doctors">
<div class="row">
<div class="col-4">
<div ng-init="ImgPath ='assets/img/' + doctor.doctorId +'.jpg"></div>
<img ng-src="{{ImgPath}" alt="" />
</div>
(...)
*ngForis a special directive in angular (2.x - 13.x), where asng-initandng-srcare directives used in AngularJS (1.x). While it sounds similar, they are very different frameworks in its implementations and do not share any code-base.