This is probably something simple but im getting something wrong.
Im trying to show a “Nothing has been posted yet” row item when the list has no items.
I use this on a MEAN stack site but its no use on Ionic
<div class="alert alert-warning text-center" data-ng-hide="!items.$resolved || items.length">
No Items yet, why don't you <a href="/#!/items/create">create one</a>?
</div>
Whats the Ionic alternative?
Thanks
Hi Chris,
I’m unsure of how your pulling your data in so i’ll provide you an example of what I do when I pull up empty search results on my app from algolia(a very fast cloud based search service provider). On your div instead of using data-ng-hide I use ng-if (or data-ng-if …if you will
) but it’s pretty much a similar test I just test if the length of the nested object with my data is <= 0 rather than falsy. I’ve been a c/c++ programmer for most of my 20 years of programming on and off and am new to javascript and working on a project as a favor so my familiarity with data types and there evaluations like what is and isn’t falsy and when/why in this language is terribly weak so I just throw whatever evaluations I can at the damn thing and keep what works untill i have time to catch my breath and read some deep dive javascript goodies.
ng-if=“results.hits.length <= 0 || !results.hits”
I receive a results data structure from my get request which if it receives results has a hits object with a list of all the found search results. For some reason I have to check null and length to ensure it catches empty results or else it doesn’t always show even though everything is blank but that is most likely due to the json object I receive back from the algolia servers.
Hope this helps, I saw your question floating around and in my experience on the boards so far actual responses to alot of questions I ask or at least look at on these boards is pretty much non existant.
1 Like