不知道为什么,但是我的控制器无法识别该服务。我已经检查了我在这里缺少的东西。我已将服务文件包含在HTML中。它不仅可以识别其他服务,还可以识别其他服务

(function() {
  'use strict';

  angular
    .module('pollyvotes')
    .service('lineChart', lineChart);

    /** @ngInject */
    function lineChart($scope, $http){
      var promise = null;
      return function(){
        if (promise){
          return promise
        } else {
          promise = $http.jsonp('')
          .success(function(data){
            $scope.predictions = data;
         })
          .error( function(data){
            $scope.data = "Request failed";
          })

          return promise;
        }

      }


控制者

(function() {
  'use strict';

  angular
    .module('pollyvotes')
    .controller('MainController', MainController);

  /** @ngInject */
  function MainController($scope, $timeout, lineChart) {

    $scope.photos = [   {id: 'chart-1', name: 'something here',src: "assets/images/300x600.png", href: "https://www.google.de/?gws_rd=ssl", discription: "say something about the chart here"},
                        {id: 'chart-2', name: 'another picture', src: "assets/images/300x600.png", href: "https://www.google.de/?gws_rd=ssl", discription: "say something about the chart here"},
                        {id: 'chart-3', name: 'another picture', src: "assets/images/300x600.png", href: "https://www.google.de/?gws_rd=ssl", discription: "say something about the chart here"},
                        {id: 'chart-4', name: 'another picture', src: "assets/images/300x600.png", href: "https://www.google.de/?gws_rd=ssl", discription: "say something about the chart here"}
                    ];

  }

})();


和声明模块

(function() {
  'use strict';

  angular
    .module('pollyvotes', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize',
                           'ngMessages', 'ngAria', 'ngResource', 'ui.router',
                           'ui.bootstrap',  'akoenig.deckgrid', 'smoothScroll',
                           'ngToast', 'picardy.fontawesome']);

})();

最佳答案

您正在为服务注入$ scope。

这就是文档中关于此错误的说明:
https://docs.angularjs.org/error/ $ injector / unpr


  尝试将范围对象注入不是控制器或控制器的任何对象
      指令(例如服务)也会抛出
      未知提供程序:$ scopeProvider <-$ scope错误。


有一个很好的答案,如何在这里避免这种情况:
Injecting $scope into an angular service function()

07-26 05:49