0
Edited: Now this example fully works with external json service to see it in live
我可以看到的console.log接收陣列而params,但我不能回顯數組的觀點...接收陣列
,網上JSON服務返回{"key": "value"}
如何使此{{some_item.key}}
正常工作?謝謝!!
<!DOCTYPE html>
<html ng-app="Simple">
<body>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script>
<div ng-controller="SimpleController">
{{some_item.key}}
</div>
<script>
angular.module('Simple', ['ngResource']);
function SimpleController($scope, $resource) {
$scope.simple = $resource('http://echo.jsontest.com/key/value',
{callback:'JSON_CALLBACK'},
{get:{method:'JSONP'}}
);
$scope.some_item = $scope.simple.get();
console.log($scope.some_item.key);
}
</script>
</body>
</html>
嘗試'$ scope.some_item [0]'。數組值通過索引訪問。 –
感謝您的提示! – Gediminas