How can I link ion-card to external url dynamically

1.9k views Asked by At

I've an ion-card that get its contents from a web server, all is working fine except linking ion-card click event to external url, below is my code

<ion-content no-padding >

      <ion-item no-padding *ngFor="let item of items" >
  <ion-card (click)="goToDetails('{{item.link}}')">



      <img class="images" src="http://mydomain/{{item.captionImage}}">

    <ion-item text-wrap>
      <div class="headings">{{item.title}}</div>
    </ion-item>
      <ion-card-content text-wrap>
        <p>{{item.message}}"</p>
      </ion-card-content>

      <ion-row>
        <ion-col col-9>
          <ion-row>
            <ion-col>


              <img class="owner-logo" src="http://mydomain/{{item.sourceLogo}}">

        </ion-col>
        <ion-col>
<div class="owner-name">{{item.source}}</div>

        </ion-col>
        <ion-col></ion-col>
        <ion-col></ion-col>
        <ion-col></ion-col>
        </ion-row>
        </ion-col>



        <ion-col col-3 text-right>
          <button ion-button clear small color="danger" icon-start (click)="regularShare(index)">
            <ion-icon name='share'></ion-icon>
            Share
          </button>
        </ion-col>
      </ion-row>

    </ion-card>
    </ion-item>

</ion-content>

my .ts file is

public goToDetails(url : string){

  let target = "_self";
  this.theInAppBrowser.create(url,target,this.options);
}

I got this error message Uncaught Error: Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 13.

1

There are 1 answers

0
Paresh Gami On BEST ANSWER

You need to write ion-card like this

<ion-card (click)="goToDetails(item.link)">

If you are in in-build directive like click, ngIf you don't need to use interpolation