O'Reilly logo

Learning Web Development with Bootstrap and AngularJS by Stephen Radford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building your own filter

As we've seen, the limitTo filter is great for truncating strings of text. I've always felt that the filter could do with appending an ellipsis should the string cross the limit. Thankfully, Angular lets us expand upon the included filters and build our own.

Modules

In order to create our filter, we first need to create what's called a module. This will enable us to attach a filter and utilize it in our views or controllers. I think the AngularJS documentation explains what a module is perfectly:

"You can think of a module as a container for the different parts of your app: controllers, services, filters, directives, and so on."

Okay great, but why would we or do we need to use one? There are a couple of reasons why you might ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required