Reputation: 150
I am dealing with that unknown provider issue, but have checked the other threads and applied those solutions to no avail. I want to get a service called 'MockSvc' to be injected into a controller without that error. Any advice helps.
app.js:
(function(){
'use strict';
console.log('enter app.js....');
var app = angular.module('app', ['ngRoute']);
})();
service:
(function(){
'use strict';
var app = angular.module('app');
app.factory('MockSvc', MockSvc);
console.log('enter MockSvc...');
function MockSvc(){
var service = {
};
initialize();
return service;
function initialize() {
console.log('enter MockSvc function init...');
};
}
})();
contoller:
(function(){
'use strict';
var app = angular.module('app', ['ngCookies']);
app.controller('PONumSearch2', PONumSearch);
PONumSearch.$inject = ['$scope', '$http', '$cookies', '$cookieStore', '$location', '$window','MockSvc'];
function PONumSearch($scope, $http, $cookies, $cookieStore, $location, $window,MockSvc){
//controller logic would be below....
})();
Upvotes: 1
Views: 43
Reputation: 222522
In controller you do not have to inject the dependencies,If you inject dependencies, it will be considered as a new module and it is instantiated again.
Change
From
var app = angular.module('app', ['ngCookies']);
To
var app = angular.module('app');
Inject ngCookies
to your Main Module,
var app = angular.module('app', ['ngRoute','ngCookies']);
Upvotes: 2