Reputation: 199
I want a way to display if something is not present then display something else.
so far I have this:
<span ng-if="likes.length = 0"> No hacks to display </span>
so if the length is zero then display this.
this code filters to order if present:
<md-list-item class="md-3-line hacks-hack"
ng-repeat="hack in hacksCtrl.hacks | orderBy: likes.length : reverse | filter:searchText | filter:hacksCtrl.filterStatus"
ng-click=hacksCtrl.goToHack(hack.id)>
not sure what i am missing, thanks
Upvotes: 0
Views: 367
Reputation: 218732
=
operator assign a value to the variable on the left side of the expression.
Use ===
or ==
for comparison.
<span ng-if="likes.length === 0"> No hacks to display </span>
===
operator won't do the type conversion before the comparison while ==
does the type conversion before the comparison.
===
(Identity operator) is the correct way to compare if both the operands are of same type.
Here is minimal a working sample
Upvotes: 2
Reputation: 1
Have you tried using ng-show instead of ng-if? ng-if only renders on the page if that statement is true. And where you're using a filter, I would suggest trying ng-show where it is simple text and wouldn't really effect rendering time.
Upvotes: 0