angular 调试时出现$http.get(...).success is not a function错误

宸紫懿 发布于 2016/12/29 20:37
阅读 1K+
收藏 0

我是angular 初学者,在调试时出现$http.get(...).success is not a function错误,我在网上找了一下,没有得到解决,求一下大神,帮我看一下出现了什么问题谢谢!

具体错误:TypeError: $http.get(...).success is not a function
    at new <anonymous> ($http2.html:24)
    at Object.invoke (angular.js:4839)
    at $controllerInit (angular.js:10692)
    at nodeLinkFn (angular.js:9569)
    at compositeLinkFn (angular.js:8878)
    at publicLinkFn (angular.js:8743)
    at angular.js:1843
    at Scope.$eval (angular.js:17958)
    at Scope.$apply (angular.js:18058)
    at bootstrapApply (angular.js:1841)


源代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/angular.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">

    <table>
        <tr ng-repeat="x in names">
            <td>{{ x.Name }}</td>
            <td>{{ x.Url }}</td>
        </tr>
    </table>

</div>

<script> var app = angular.module('myApp', []); app.controller('customersCtrl', function customersCtrl ($scope, $http) {
        $http.get("../json/json.txt")
                .success(function (response) {$scope.names = response.records;});
    });
</script>

</body>
</html>

加载中
返回顶部
顶部