Thanks. I tried so many posts but this one works for me. For others, I will post my experience here. For my testing, my asp.net core API returns a student list with byte[] data type image which is mapped to Blob in Angular.
In addition, in Angular field names in a class must start with a lower case for reference regardless of their declaration. eg.
Student.Photo; // is declared in a Student class.
students: Student[];
//Call an api and put the result into students.
students[0].photo worked. But students[0].Photo caused an error of 'undefined'.
For working sample of multiple images, please see the below codes.
--Angular component HTML -----
<tr *ngFor="let item of studentList">
<td>{{item?.given1}} -- {{item?.surname}}</td>
<td>
<img [src]="getImangeUrl(item?.photo)"/>
</td>
</tr>
-- in component.ts file
public getImangeUrl(photo:Blob): any {
if (photo === null)
return "";
else
{
let objectURL = 'data:image/jpeg;base64,' + photo;
return this.sanitizer.bypassSecurityTrustUrl(objectURL);
}
}
Finally it works for me. Most examples are only for a single image which is very easy to do it as the above example. Happy coding!