In angularjs
I have made sure to register a service like this, inside the services directory inside modules -> module_name
angular.module('module_name').factory('service_name', [
function() {
// Public API
console.log('hello');
return {
someMethod: function() {
return true;
}
};
}
]);
from this Error: Unknown provider: employeesProvider <- employees i found removing the ngController solves the issue, but I am trying to render a view that must have a controller to render some model data.
If i remove that ngController, i get no data.
What do i do?
It looks like you have dependency on the employees module (somewhere not shown in your posted code). You need to inject that into this module_name.
angular.module('module_name',['employees'])
.factory('service_name', ['employees', function(employees) {
// Public API
console.log('hello');
return {
someMethod: function() {
return true;
}
};
}]);
The dependency could also be in your controller. You should use the similar method to inject the dependency there.
Additional information on dependency injection .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.