AngularJS [$ injector:unpr]未知的提供者

时间:2015-07-17 15:27:53

标签: angularjs error-handling angularjs-injector

我可以根据我的代码向我提供有关我为何会在标题中收到错误的见解吗?不太清楚为什么。

Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-beta.17/$injector/unpr?p0=serverProvider%20%3C-%20server
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:6:457
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:37:55
at Object.d [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:74)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:37:129
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:74)
at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:335)
at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:494)
at $get (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:69:169)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:54:454

我已经多次查看代码,试图找出导致错误的原因,但无济于事。是因为我在控制器和工厂之间呼叫?

编辑:这是错误

<?php

    // Create an array of domains
    $domains = ['www.example.com', 'www.example2.com', ...];

    // Cycle through all the domains and run the code
    foreach($domains as $domain) {

        $domain0='www.example.com';
        $file=$_GET['file']
        $resourceUrl = 'http://$domain0/$file';
        $resourceExists = false;

        $ch = curl_init($resourceUrl);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_exec($ch);
        $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        //200 = OK
        if($statusCode == '200') { 
            $resourceExists = true; 
        } else if($resourceExists == false) {

        }

        if ($resourceExists == true) {
            echo "Exist! $file";
        } else {
            echo "$file doesnt exist!";
        }

    }

?> 

1 个答案:

答案 0 :(得分:0)

根据返回的错误,更改

  .controller("CreateGrids", ['$routeParams', '$scope', '$http', 'setup', 'server', 'gridservice', function ($routeParams, $scope, $http, setup, servers, gridservice) {

 .controller("CreateGrids", ['$routeParams', '$scope', '$http', 'setup', 'servers', 'gridservice', function ($routeParams, $scope, $http, setup, servers, gridservice) {

您将服务器错误称为服务器。

对于未来的知识 - 当angular为您提供错误堆栈时,请单击顶部超链接,它将带您进入一个页面,告诉您更多有关错误的信息。此链接供参考 - here