I've been working on Dependency Injection and trying to make my code more modular in Angular.js. After researching some tutorials, I decided to try and rewrite it.
Here's what I initially planned (although I may have misunderstood some concepts, so any guidance is appreciated):
Create an ng-app: "myapp";
Create a module called "finance2" with a factory service named "currencyConverter":
angular.module('finance2', []).factory('currencyConverter', function() {
Create a module called "ctrl1" with a controller named InvoiceController. Then inject the service module into it:
angular.module('ctrl1',['finance2']).controller('InvoiceController', ['currencyConverter', '$scope',function(currencyConverter,$scope) {
- Inject the controller module into the app:
var app = angular.module("switchableGrid",['ctrl1']);
Here is the full code: jsfiddle.net/c7fF3/1/
However, nothing seems to be happening. Can someone provide me with a hint? Thank you.