Wednesday, September 2, 2015
Inject Controller to Application
In AngularJS Dependency Injection
is achieved by injecting objects to the controller, also we can create
different controller objects and inject them to the application. In normal
implementations we use the $scope
object in the controller to set values and pass it to the view for display.
In the following example we shall create a controller and inject the controller to the application, this way all the data used in the application are fed from the injected controller, the injected controller can be changes or pass different controller objects to test the view.
In the following example we shall create a controller and inject the controller to the application, this way all the data used in the application are fed from the injected controller, the injected controller can be changes or pass different controller objects to test the view.
Inject Angular Factory to Controller
In AngularJS Dependency Injection
is achieved by injecting objects to the controller, in normal implementations
we use the $scope object in the
controller to set values and pass it to the view for display.
In the following example we shall create a factory and inject the factory to the controller, this way all the data used in the controller are fed from the factory, the factory can be changes or pass different factory objects to test the controller and the view.
In the following example we shall create a factory and inject the factory to the controller, this way all the data used in the controller are fed from the factory, the factory can be changes or pass different factory objects to test the controller and the view.
Subscribe to:
Posts (Atom)