Learn Angular JS In 10 minutes

Config/Factory/Service/Controller Example

This example provides the usage of following components in angular -js., in a simple example.

The following example provides the details of all the below components, so we can use it for an enterprise application very easily.

  • Config
  • Factory
  • Service
  • Constants
  • Controller

Config – Config is nothing but the Configuration block which is called during angular-js startup.

  1. Set a default value in configuration.
  2. Initialise a factory method in configuration.
  3. Inject a directive during angular js startup in the application.

Angular JS(Config/factory/Service/controller) Example:

HTML Page Output:
AngularJS – All in One- Simple Example

AngularJS Sample Application – {{siteHeader}}

Enter anything to count:

Word Count: {{wordcountresult}}

Letter Count: {{lettercountresult}}

Once the HTML/Angular-JS is executed, the console.log(“”) statements will be printed in the browser developer tools->console tab

(Press F12 for most browsers)

It will display the Order of methods initialised and called for the code above.

Console Output (F12 – Inspect – Browser Console)

Leave a Reply

Your email address will not be published. Required fields are marked *