I get, this error
Error: [ng:areq] http://errors.angularjs.org/1.4.7/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20undefined
when I try the following
HTML
<div ng-app="angularmodule">
<div ng-controller="mycontroller">
<div class="mydirective" </div>
</div>
Directive
angular
.module('ui.module', [])
.directive('mydirective', function () {
//some directive stuff in here, restricted as ‘C’
}
};
});
Factory
angular
.module('dataLayerModule', [])
.factory('datalayer', [$http],
function (http) {
//some method in here that uses http request
return factory;
});
Controller
angular
.module(‘angularmodule’, [‘ui.module', 'dataLayerModule'])
.controller('mycontroller', ['$scope', 'datalayer', function ($scope, datalayer) {
//this is dependent on two modules being injected i.e. ‘ui.module','dataLayerModule'
}]);
If I strip out the factory ('dataLayerModule') module injection from the just above it works e.g
angular
.module('angularmodule’, ['ui.module'])
.controller('mycontroller', ['$scope', function ($scope) {
}]);
The problem is my 'dataLayerModule’ injection and it’s 'datalayer' factory are not being injected, I think. The angular javascript code above are in different files but are correctly loaded in the html.
What I’m trying to do is inject the factory into the controller, the factory will be responsible for getting json data via ajax
The reason for these different modules is that the 'ui-module' comes from a 3rd party which I have no control over.
If anyone can create a plunker, with this injection just functioning/loading correctly I'd be so grateful, this is driving me mad