我在尝试访问json文件时遇到问题。我使用警报来确定它是否正常工作但由于某种原因它不是。我想知道你们中是否有人知道为什么,谢谢
app.controller("MainController", function($scope, $http) {
$http.get('/Users/singh/Documents/twilioproject/Public/patients.json').success(function(data) {
alert('worked');
$scope.patients = data;
});
});
答案 0 :(得分:2)
原来是这样的:
"Patient":[
{
"name": "John Smith",
"date": "12/22/2016",
"number": "+10813924630"
},
{
"name": "Johsddn Smith",
"date": "12/22/2016",
"number": "+14813924640"
}
]
我改变它之后就起作用了:
[
{
"name": "John Smith",
"date": "12/22/2016",
"number": "+15812914640"
},
{
"name": "Johsddn Smith",
"date": "12/22/2016",
"number": "+17813923440"
}
]