【发布时间】:2014-08-20 03:01:42
【问题描述】:
我正在使用 Cordova 和 Angular JS 开发一个移动应用程序。我的应用程序位于 easyphp 本地主机上。 我在 index.html 中使用带有 ng view 指令的 Angular Routes。我有这个:
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)。我哪里错了?
感谢您的帮助,
问候
【问题讨论】:
-
在 ViewCtrl 中,您忘记将依赖
$http作为字符串传递,然后再将其作为参数传递
标签: angularjs