-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Data Oriented Development with Angularjs
By :

It often happens that we need to show filtered data. In this case, we can include logic in one of the functions in a service. However, this logic can get lost if a service has many methods. Similarly, we might have to format some data before showing it in the view. Angular introduces filters for precisely these things—either format the value of an expression for display or filter values from an array. Angular comes with some of the most common filters to format number, currency, or date. Refer to the built-in filters available at https://docs.angularjs.org/api/ng/filter.
Let's write a custom filter. In our previous example, our service returns some employees. Let's add a few more employees whose age is more than 58 years. Let's assume that the retirement age is 60 years, and anyone whose age is 58 years or more is about to retire. Then, let's filter the employees. So, here's the modified service:
'use strict'; app.service('employeeSvc', function () { var Employee = function (name...
Change the font size
Change margin width
Change background colour