Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49228

Ng-repeat filter crashes if array is empty

$
0
0

@jacobriprap wrote:

I am trying to filter a ng-repeat within a scroll box based on a users value, but if the array is empty, the page crashes. I want all users with value 1 to be in one slide, value 2 in another etc.

If there is an object in the array with value === 1, then there's no problem, but as soon as there is no object with the correct value, then the page crashes.
I would like to have a text like: "No users with value 1"

<ion-slide>
<div class="item item-avatar" ng-repeat="item in items | filter: filter1">
<img ng-src="{{item.imgSrc}}">
<h2>1{{item.username}}</h2>
</div>
</ion-slide>

$scope.filter1 = function(item){
if (item.status === '1'){
return true;
} else{
return;
}
};

The objects in the array looks like this:
imgSrc: "placeholder.png"
status: "1"
username: "username"

How can i solve this problem?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49228

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>