我正在玩 angularjs。我试图简单地从 json 文件中提取数据。当我运行代码时,文件显示在网络中,但数据未显示在页面上,并且我在控制台中收到以下错误:
TypeError: undefined is not a function at Ob (lib/angular-1-2/angular.min.js:14:6)
我正在使用的代码如下:
var Services = angular.module('Services', ['ngResource']);
Services.factory('reportFactory', function($http){
console.log(REPORT_LIST_URL);
return{
getReports: function(callback){
$http.get(REPORT_LIST_URL).success(callback);
}
}
});
function ReportsCtrl($scope, $http, reportFactory) {
$scope.reportsList = [];
console.log($scope.reportsList);
console.log("Get report list from json file");
console.log("before the factory");
reportFactory.getReports(function(data){
$scope.reportsList = data;
});
}
json 文件示例
{
"Reports": {
"Productivity": [
{
"name": "Productivity Summary",
"value": "Productivity"
},
{
"name": "Time Summary",
"value": "TimeSummary"
}
]
}
}
非常感谢任何帮助或建议。
谢谢