Skip to main content

Posts

Showing posts with the label angularjs dependency injection example

angularjs dependency injection example

Hello everyone,  I am going to share the example for how to work the angularjs dependency injection.  The example with detail explanations as given below, please follow  below steps. Step 1 :  In The below example code, the factory and provider methods are run. That means the injector ( $injector ) are inject the dependencies. Step 2 :  In The below example code, the AngularJs binds the controller to DOM. Demo link click on http://embed.plnkr.co/Snv9zO/preview AngularJs dependency injection code as given below. var app = angular.module( 'appDI' , []); //factory method app.factory( 'diFactory' , function () {     return {         user: {             name: 'Anil Singh'         },     }; }); //provider method app.provider( 'diProvider' , function () { ...