ngFor="let user of users" question

#1

Hi all,

When I use in the .html:

<ion-card *ngFor="let user of users">
  <img src="{{ user.field_image }}">

Then the image is on the html page.

There is also a {{ user.link }} but I have to put that in an In-app-browser within a ngoninit in the .ts file, what do I have to do to do that in the right way?:

ngOnInit(){

        const browser = this.iab.create('user.link',{location:'no'});

    }

I have to do more than this in the .ts file?

#2

Hi @RenzoM78 :wave:

Assuming you want to open the link when tapping on the card, maybe you can do something like this:

In the template:

<ion-card *ngFor="let user of users" (click)="openBrowser(user.link)">
  <img src="{{ user.field_image }}">
</ion-card>

In the page class:

openBrowser(url: string) {
  const browser = this.iab.create(url, { location:'no' });
}

Best,
Rodrigo

#3

Hi Rodrigo, thanks for the answer, i will try it. It looks simple in your answer :slight_smile: