Tip:
Highlight text to annotate it
X
So let's explore a few more filters provided by AngularJS.
So the first one we're going to look at is called orderBy.
And we can order by the name.
So if I just refresh from here, you can see we're now
sorting by Alexis, and Chris, and Chris, and
going down to Tom.
So these things are ordered alphabetically.
If you put a minus sign in front, this will sort them
from the reverse order.
What else can we do here?
We can do a limitTo if we only want five results.
So you can see this limits the results at only five.
Negative five would limit it to the last five results.
We could also start stacking these things.
So we can say orderBy, and we'll say orderBy Name.
And then another pipe will stack the filters on top of
each other.
So it's going to order by the name and
limit to the last five.
So we got Samuel, Scarlett, Stellan.
These are the last five on the list.
Again, this would be the first five--
so Alexis down to Cobie.
And then we can do the reverse order, limit
it to five, et cetera.
And then we can take everything we have there, add
another pipe, and add that search filter back on.
And you can see now that we have a searchable list of
names ordered by name, limited to five.
And you can search on them now.
So that's pretty awesome.
And there's also filters like lowercase if you just want to
lowercase a simple property like that, or uppercase if you
just want to uppercase.
You can see I already have these applied for
Chris and for Steve.
And that's how you stack filters and use a bunch of the
filters that AngularJS already provides for you.