模块服务不可用注入服务

module service is not available injecting service

本文关键字:服务 注入 模块      更新时间:2023-09-26

http://plnkr.co/edit/AmuC4CpfMnP9ySmOI54C?p=preview

var app = angular.module('plunker', ['extraService']);
app.controller('MainCtrl', ['$scope', '$http', 'extraService', function ($scope,$http,extraService) {
  $scope.name = 'World';
}]);
app.service('extraService',function(){
  return 'abc';
});

我的服务注射怎么了?为什么我得到模块服务extaService不可用错误?

在声明模块时不需要注入服务extraService

使用

var app = angular.module('plunker', []);

而不是

var app = angular.module('plunker', ['extraService']);