【发布时间】:2017-03-28 20:28:11
【问题描述】:
我已经为此工作了几个小时,但似乎无处可去。我希望这是发布此内容的正确位置。我是 StackOverflow 的新手,所以如果这不正确,请引导我到正确的地方。
我有以下 html 文件:
<!DOCTYPE HTML>
<html ng-app="DishClips">
<head>
<script type="text/javascript" src="http://code.angularjs.org/angular-1.0.0.0rc4.min.js"></script>
<script type="text/javascript" src="http://code.angularjs.org/angular-resource-1.0.0.0rc4.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css">
<script type="text/javascript" src="./dishclips.js"></script>
</head>
<body>
<div ng-controller="DishClipsCtrl">
<table class="table table-striped">
<tr ng-repeat="restaurant in dishclipsResult.results"></tr>
<td>{{restaurant.name}}</td>
</table>
</div>
</body>
</html>
以及我的 discclips.js 中的以下内容:
angular.module('DishClips', ['ngResource']);
function DishClipsCtrl($scope, $resource) {
$scope.dishclips = $resource('http://apiv2.dishclips.com/dishclips/api/:action',
{action:'searchRestaurants',address:'irvine',callback:'JSON_CALLBACK' },
{get:{method:'JSONP'}});
$scope.dishclipsResult = $scope.dishclips.get();
}
当我运行这个(在 chrome 中)时,我得到:
Uncaught SyntaxError: Unexpected token :
json 返回看起来很棒,所以我不明白为什么这是一个问题。
谢谢
【问题讨论】:
-
使用 Angular 的开发版本而不是缩小版本,然后告诉您的浏览器在异常之前中断。堆栈跟踪可能包含有用的信息。
-
你解决了吗?
标签: angularjs