How use binding with ngFor on html?


#1

Hi all !
I’m a beginner in Ionic and Angular. Then, I tried to use binding some html and i don’t succeed and don’t understand how to use it. I search but i don’t found someone who simply explains it for beginners …

Maybe i don’t found but if someone can help me, it would be really cool ! :slight_smile:

Actually, i want bind some <ion-slide> in <ion-slides>. I need to use bind because i use a “for” to create it.

Ty !

PS : sorry for my English, i’m French :upside_down_face:


#2
//HTML
<ion-slides *ngIf="imageurl && imageurl.length" autoplay="2000" loop="true" speed="1000" style="height:36%;" pager="true">
    <ion-slide *ngFor="let imgu of imageurl" id="{{imgu.ID}}">    
      <img src="{{imgu.ImagePath}}" style="height:202px;">
    </ion-slide>
</ion-slides>

//TS
imageurl:any =
[
  {"ID":"1","ImagePath":"url"},
  {"ID":"2","ImagePath":"url"}
];

#3

Thank you for your help !
If data is retrieved from a database, i seen we need to use SafeUrl for the <img> url if I’m not mistaken ?


#4

Off-topic:
Hah! Now you HAVE to speak English :rofl::rofl:


#5

for that you need to use DOMSanitization to use image.