2016-03-22 4 views
0

у меня есть HTML-файл, как это:ошибка Инъекции в угловых

<html> 
    <head> 
     <title>PLD Interaction pattern</title> 
     <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/> 
    </head> 

    <body ng-app="myTmoApppdl" ng-controller="populateObjsController"> 

     <!--Angular JS--> 
     <script src="Scripts/angular.min.js" type="text/javascript"></script> 
     <!--User defined JS files--> 
     <script src="Scripts/app.js" type="text/javascript"></script> 
     <!--<script src="Scripts/server.js" type="text/javascript"></script>--> 
     <!--Controllers--> 
     <script src="Scripts/Controllers/populateObjsController.js" type="text/javascript"></script> 
     <!--Services--> 
     <script src="Scripts/Services/populateObjsService.js" type="text/javascript"></script> 
     <!--Digital Data--> 
     <script src="Scripts/digital-data/digitaldata.js" type="text/javascript"></script> 
     <!--PDL Files--> 
     <script src="Scripts/pdl-module/pdl-module/pdl-config.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/pdl-constants.js" type="text/javascript"></script> 
     <!--PDL Utils--> 
     <script src="Scripts/pdl-module/pdl-module/utils/pdl-page-util.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/utils/pdl-event-util.js" type="text/javascript"></script> 
     <!--PDL Services--> 
     <script src="Scripts/pdl-module/pdl-module/services/console-handler-factory.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/ensighten-handler-factory.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-account-event-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-cart-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-device-detector-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-directive-decorators.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-event-handler-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-geo-location-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-interceptor-factory.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-language-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-navigate-event-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-offerset-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-profile-event-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-provider.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/pdl-rep-dash-service.js" type="text/javascript"></script> 
     <script src="Scripts/pdl-module/pdl-module/services/transaction-data-service.js" type="text/javascript"></script> 
    </body> 
</html> 

Контроллер:

//Creating or defining controller 
app.controller('populateObjsController', function (populateObjsService) { 
    console.log("printing Root object or PDL:", digitalData); 
}); 

Услуга:

app.factory('populateObjsService', function ($scope, $http) { 
    return { 
     printData: function() { 
      console.log("service called"); 
     } 
    }; 
}); 

Я получаю ошибку, когда я использую нг-контроллер = populateObjsController внутри тега тела. Его простое приложение, но все еще бросает ошибку, я не могу понять, что пошло не так?

Ошибка:

angular.min.js:107 Error: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20populateObjsService 
    at Error (native) 
    at http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:6:416 
    at http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:41:121 
    at Object.d [as get] (http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:39:92) 
    at http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:41:195 
    at d (http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:39:92) 
    at Object.e [as invoke] (http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:39:362) 
    at Object.$get (http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:37:311) 
    at Object.e [as invoke] (http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:39:394) 
    at http://localhost:8084/PopulateProductObject/Scripts/angular.min.js:41:224 
+0

Устранение проблемы «$ scope» устраняет проблему – Satyadev

ответ

0

заводы не имеют $scope для инъекций. Убери это!

app.factory('populateObjsService', function ($http) { 
Смежные вопросы