1

I am trying to get a value in html using interpolation. For that i use interpolation inside the array[] like sessions[{{item.sessionNumber}}] to get the index. Still I cant get the result

<ion-item class="item" text-center no-lines *ngFor="let item of token let i=index">
  Time:{{item.client[0].sessionDetails.sessions[{{item.sessionNumber}}].startTime}}
</ion-item>
2
  • 1
    Why double interpolation is there, it is not required at all, one is enough, the outside one. And can you put more detail like data structure that would help us to identify solution. Commented Sep 13, 2018 at 8:34
  • inside this sessions[{{item.sessionNumber}}] this interpolation to get another value here to get the starttime from array Commented Sep 13, 2018 at 8:44

2 Answers 2

1

In your example, you do not need to use interpolation inside interpolation.

Since the template syntax is JavaScript like, the following should work.

<ion-item class="item" text-center no-lines *ngFor="let item of token let i=index">
  Time:{{ item.client[0].sessionDetails.sessions[item.sessionNumber].startTime }}
</ion-item>

This assumes you have an object in the component with the following structure:

item = {
  client: [{ 
    sessionDetails: {
      sessions: [ { startTime: "12:00"} ]
    }   
  }],
  sessionNumber: 0
};
Sign up to request clarification or add additional context in comments.

Comments

0

call a function and send the index. you can't use interpolation like this

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.