0

how can i use {{ }} in src of a image? i got error with this code near [src]

    <ion-list>
  <ion-item *ngFor="let item of results| async">
    <ion-thumbnail slot="start">
      <ion-img [src]={{ item.qrlink }}></ion-img>
    </ion-thumbnail>
    <ion-label>{{ item.Title }}</ion-label>
  </ion-item>
</ion-list>

in the page.ts i have this code:

 submit_newcheck()
  {
  this.results = this.encryptionService.newcheck(this.checkid,this.cost,this.toname,this.tocode,this.passcode,this.date );

  }

which is connected to a service like this:

export class EncryptionService {
     constructor(private http: HttpClient) { }

    newcheck(checkid: string ,cost: string,toname: string,tocode: string,passcode: string,date: string): Observable<any> {
    return this.http.get(`https://api.test.com/encrypte.php?checkid=${encodeURI(checkid)}&&cost=${encodeURI(cost)}&&toname=${encodeURI(toname)}&&tocode=${encodeURI(tocode)}&&passcode=${encodeURI(passcode)}&&date=${encodeURI(date)}`).pipe(
      map(results => results['Data'])
    );
  }
}

1 Answer 1

4

It should be either be [src]="item.qrlink" or src={{ item.qrlink }}. They aren't supposed to be mixed together.

Explanation

In case of [src]="item.qrlink" the value of variable item.qrlink is bound to the [src] property using property binding. Read up more on template expression here.

In case of src={{ item.qrlink }} the value item.qrlink is interpolated and assigned to the attribute src. Read up more on interpolation here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.