我正在用Cordova和Angular JS开发一个移动应用程序。我的应用程序运行在easyphp本地主机上。在我的index.html中,我使用带有ng视图指令的角度路由。我得到了这个:
TypeError:无法读取未定义的属性“”get“”
angular.module('app.controllers', [])
.controller('MainCtrl', ['$scope', function ($scope) {
$scope.status = "Accueil";
}])
.controller('ViewCtrl', ['$scope', function ($scope, $http) {
$http.get('mobile.php/getAnnonces/limit=10')
.success(function(data, status, headers, config) {
$scope.posts = data;
})
.error(function(data, status, headers, config) {
// log error
});
}])
...
如果我测试这个URL,我的脚本将返回JSON (使用json_encode)。我哪里错了?
谢谢你的帮忙,
问候
发布于 2014-06-30 01:06:28
试着改变
angular.module('app.controllers', [])
.controller('MainCtrl', ['$scope', function ($scope) {
$scope.status = "Accueil";
}])
.controller('ViewCtrl', ['$scope','$http', function ($scope, $http) {
$http.get('mobile.php/getAnnonces/limit=10')
.success(function(data, status, headers, config) {
$scope.posts = data;
})
.error(function(data, status, headers, config) {
// log error
});
}]);
更改:将$http
服务作为字符串传递给控制器,以便在运行时解析。
https://stackoverflow.com/questions/24478293
复制相似问题