How can I get Ng-Repeat working with undefined objects?

Hey guys,

I am a complete beginner and after having a lot of fun with the ionic framework, I’ve run into an issue I can’t solve.

I have a server set up that sends a json object to the ionic app. This works great and I can access an individual item’s text by using {{postdata[0].posttext}} without any problems.
Now I wanted to do:

<div ng-repeat="post in postdata"> {{post.postdata}} </div>

And I just can’t get it to work. It always say that post is undefined.I tried hundreds of multiple combinations… I read that I may need to inculde an empty dependency module. If that’s the right solution how do I do that and if not does somebody know what my problem is ?

Thank you very much !

JamToak

Initialize postdata to an empty array where you declare it.

Hmm, I had it declared as a string… now it is like this (which I don’t think is the right way to do it):

postdata =[ ];

//before that it was


postdata: string ='';

Thank you very much btw. rapropos - I really appreciate it!

I’m now sort of confused as to which category this belongs in. On one hand, you’ve got ng-repeat, which is v1 syntax, but on the other you’ve got what appears to be a TypeScript type declaration. Are you using v1 or the current Ionic version?

I am using the current version and typescript
What do I have to use instead of Ng-Repeat then ?

The conflicting information in the web is very confusing for a complete beginner at this kind of stuff, but aside from that I was pleasantly surprised how fast I could build a complete Signup, Sign-in and Profile System (Client and Server Side) :smiley:

And sorry that this reply took so long - the website said that I was replying too fast :confused:

ngFor. And incidentally, postdata = [] is more or less what I was suggesting. That’s just fine.

1 Like

Thank you very much - I’ll come back to you tomorrow (zzz) and mark it as the solution if it solved it.