Sunday 5 June 2016

Visibility of the Factory across the modules in angular Js

In this post we are going to see the visibility of Factory across the modules in angular Js, Generally whenever we create a factory we will inject the dependencies for that factory,If the Dependency is from another Module,then we will inject that module to the Factory related module, But instead of doing like we can get the Visiblity of that module while injecting from the root module and we can get the instance across the module.

For Example: Let we take two difference modules Department and Employees. Each module have a Factory

Department - > Factory Development

Employees -> Factory Developer   (Depends on the Development Factory needs Department module to be injected), But instead of inject the module, we are injecting the  Development Factory to Developer Factory, Later in the main module we are injecting the all module, so now the visiblity of Deparment module is across the modules.

App.Js
*****************












Html:
**************




Output:
**************





From this post you can learn the visibility of the modules in angular js.

No comments:

Post a Comment