2013-12-22 51 views
-1

我第一次尝试AngularJS和我卡在我的第一个get方法。AngularJS JSON GET从PHP文件

凡在jQuery的我会使用$阿贾克斯()我已经得到了下面,我得到一个错误

var theApp = angular.module('theApp', []); 
theApp.controller('ContentController', ['$scope', function ($scope) { 

}]); 
theApp.controller('MenuSideController', ['$scope', function ($scope, $http) { 
    $http.get('/directory/assets/inc/category.php').success(function(data) { 
     $scope.list = data; 
    }); 

}]); 

的错误,我得到

TypeError: Cannot call method 'get' of undefined 

回答

3

你不指定字符串版本$http在您的参数列表中,所以Angular不通过该服务。

更改此行:

theApp.controller('MenuSideController', ['$scope', function ($scope, $http) 

要这样:

theApp.controller('MenuSideController', ['$scope','$http', function ($scope, $http)