错误:角度js中的[$ injector:unpr]

时间:2016-09-17 06:35:50

标签: javascript php angularjs

我是AngularJS的新手。我不知道如何在post方法中获得响应。我得到了如下错误。我只是在控制台中打印响应值。我想知道需要添加哪些JS文件。

 angular.js:12330 Error: [$injector:unpr] http://errors.angularjs.org/1.4.3/$injector/unpr?p0=%24httpProviderProvider%20%3C-%20%24httpProvider%20%3C-%20myapp at Error (native at)

请帮我解决问题

app.js

var app= angular.module('demo', ['ngRoute']);
app.controller('myapp', ["$scope", "$http" ,"$q","$httpProvider", function($scope, $http, $q,$httpProvider) {
      $httpProvider.defaults.useXDomain = true;
                $httpProvider.defaults.withCredentials = true;
                delete $httpProvider.defaults.headers.common['X-Requested-With'];   
        var data = $.param({
            json: JSON.stringify({
                id:'SYZ2015011'
            })
        });
        console.log(data);
        $http.post('http://syzygyapp.com/apistaffattendance/index.php/api/employee/getEmployeeHours', data, config)
            .success(function (data, status, headers, config) {
                 $scope.hello = result;
            console.log($scope.hello);
            })
            .error(function (data, status, header, config) {
                $scope.ResponseDetails = "Data: " + data +
                    "<hr />status: " + status +
                    "<hr />headers: " + header +
                    "<hr />config: " + config;
            });



}]);

index.html
    <!doctype html>
    <html ng-app="demo">
    <head>
    <title>Hello AngularJS</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
    <script src="js/angular-route.min.js"></script>
            <script src="app.js"></script>
    </head>
    <body>
    <div ng-controller="myapp">
    <!-- <p>The ID is {{greeting.id}}</p>
    <p>The content is {{greeting.content}}</p> -->
    <table class="table table-striped table-bordered">
            <thead>
            <th>Field1&nbsp;</th>
            <th>Field2&nbsp;</th>
            <th>Field3&nbsp;</th>
            <th>Field4&nbsp;</th>
         </thead>
            <tbody>
                <!-- <tr ng-repeat="data in greeting">
                    <td>{{data.body}}</td>
                    <td>{{data.id}}</td>
                    <td>{{data.title}}</td>
                    <td>{{data.userId}}</td> -->
                    <!-- <td>{{data.country}}</td>
                    <td><a href="#/edit-customer/{{data.customerNumber}}" class="btn">&nbsp;<i class="glyphicon glyphicon-edit"></i>&nbsp; Edit Customer</a></td> -->
               <!--  </tr> -->
            </tbody>
            </table>
            </div>
        </body>
    </html>
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
    <script src="app.js"></script> -->

0 个答案:

没有答案