O'Reilly logo

Learning AngularJS by Brad Dayley

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

Implementing a Simple Application That Uses All Four Types of Services

In this example you will build constant, value, factory, and service services. The purpose is to give a chance to see how each can be implemented, as well as the perspective of using multiple types of services in your applications.

The code in Listing 10.1 shows an example of integrating value, constant, factory, and service services into a single module. The example is very basic and easy to follow. Notice that censorWords and repString are injected into and used in the factory and service definitions.

Lines 4–13 implement a factory service that returns a function that censors a string. Notice that line 26 calls the factory directly to censor the string.

Lines 14–25 implement ...

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