1

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?

Community
  • 1
  • 1
codeofnode
  • 18,169
  • 29
  • 85
  • 142

1 Answers1

0

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.

Saeed D.
  • 1,125
  • 1
  • 11
  • 23