Gayatri Tallapragada
Gayatri Tallapragada

Reputation: 13

angular2 External link redirect by clicking on the items loaded

I am trying to create an application using Ionic2 angular2. Been using it for quite sometime now. I want to open google page search for the item that is loaded dynamically in the view

for creating the view I have the following code.

this.initializeItems();
  }
  initializeItems() {
    this.items=[

    'Tennis',
    'cricket',
    'Football',
    'Table tennis',
    'Badminton',
  ];
  }

So when I click each Item it should open the google search page as

Can someone tell me how to do this.

Upvotes: 0

Views: 71

Answers (1)

Ivar Reukers
Ivar Reukers

Reputation: 7719

<div *ngFor="let item of items">
    <a [href]="'https://www.google.com/search?q='+item">Search {{item}}</a>
</div>

OR

<div *ngFor="let item of items">
    <a [attr.href]="'https://www.google.com/search?q='+item">Search {{item}}</a>
</div>

Not sure if you'll need the attr but I do think so.

Upvotes: 1

Related Questions