2

I have a problem with my code.

I want to show all my data as ion item but it's showing nothing.

This is my HTML part :

<ion-item  *ngFor = "let item of test"class="col1" col-12 style=" border: none; color:black;text-align: center;">
                                {{item.description}}    
</ion-item>

And this is my TS part :

let item = 0;
for(let i = 0; i < this.test['0']['data'].sidelined['data'].length; i++){
     let item = this.test['0']['data'].sidelined['data'][i];
     this.item = item;
     console.log(this.item.description);
}

Console log give me all the informations as i want to show. But HTML don't show anything.

Any idea? Thanks

3
  • don't work with scope Commented Nov 11, 2018 at 13:43
  • 1
    @BartoszTermena This is Angular not AngularJS so $scope does not exist. Commented Nov 11, 2018 at 14:00
  • where did you define and initialize variable test ? Commented Nov 11, 2018 at 18:07

1 Answer 1

1

I'm not really sure what you want to do there. The code is looking kind of broken.

In your typescript code you are reassigning to this.item multiple times - effectively overwriting this.item multiple times. I guess you want to print one line in your html for every entry in this.test['0']['data'].sidelined['data']. In this case you will have to assign that to your item:

this.item = this.test['0']['data'].sidelined['data']

and in your html:

<ion-item *ngFor="let entry of item">
    {{entry.description}}    
</ion-item>
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.