angularJS中的$ http.get错误-成功不是函数

收到此错误:


angular.min.js:122 TypeError:$ http.get(...)。success在Object.invoke(angular.min)的new(app.js:12)的getUserInfo(app.js:7)处不是函数.js:43)在Q.instance(angular.min.js:93)在p(angular.min.js:68)在g(angular.min.js:60)在g(angular.min.js:61) )在g(angular.min.js:61)在angular.min.js:60在angular.min.js:21


这是我的代码:


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


gitHub.controller('mainController', ['$scope', '$http', function($scope, $http) {


    var $scope.user = '';

    function getUserInfo($scope, $http){ 

        $http.get('https://api.github.com/users')

            .success(function (result) {

                $scope.user = result;

                console.log(result);

            });

    };

    getUserInfo($scope, $http);

}]);

这是HTML


<!DOCTYPE html>

<html ng-app="gitHub">

<head>

    <title>Github Users Directory</title>

    <script src="angular.min.js"></script>

    <script src="app.js"></script>

</head>

<body>

    <div ng-controller="mainController">

        <div>

            <h1>GitHub Users</h1>

            Who do you want to search for?<input type="text" name="FindHim" ng-model="queryName" />

            <button ng-click="getUserInfo()">Search</button>

        </div>

        <div>

            {{ user }}

        </div>


    </div>

</body>

</html>


慕侠2389804
浏览 723回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

AngularJS