Skip to content Skip to sidebar Skip to footer

Angular Uncaught ReferenceError: Service Is Not Defined

I have the following component in which I am trying to inject a service: angular. module('phoneList'). component('phoneList', { templateUrl: '/static/common/angular/phone-l

Solution 1:

It seems the service isn't properly injected into the PhoneListController.

Change it to:

controller: ['$http', 'authenticationService',
  function PhoneListController($http, authenticationService) {
...

The strings in the array are just to keep the injected dependency references minification safe. The service still needs to be added as a function argument.

Also be sure to call angular.module once for each component:

app.module.js

angular.module('phonecatApp', [
  'ngRoute',
  'phoneList',
  'authentication',
]);

phone-list.module.js

angular.module('phoneList', ['authentication']);

Post a Comment for "Angular Uncaught ReferenceError: Service Is Not Defined"