我是Angular.js的新成员。我试图从我的本地url http://85.96.243.31/admin.productss/searchwithjson获取json。 JSON内容是:将JSON加载到角度
[
{
"fullsizeurl": "/uploads/incubout_denemeshop/1/product/3-kdd4eesv-erer-1-cent-1.png",
"productid": "3",
"price": "0.01",
"isactive": 1,
"brandid": "1",
"subcategoryid": "1",
"model": "1 Cent",
"isbundle": 0,
"subcategory": "Cat2",
"taxincluded": 0,
"brand": "erer",
"thumbnailsizeurl": "/uploads/incubout_denemeshop/1/product/3-kdd4eesv-erer-1-cent-1_thumb.png"
},
{
"productid": "1",
"isactive": 1,
"isbundle": 0,
"taxincluded": 0,
"thumbnailsizeurl": "/uploads/incubout_denemeshop/1/product/1-gu60axs2-erer-model-1_thumb.png",
"fullsizeurl": "/uploads/incubout_denemeshop/1/product/1-gu60axs2-erer-model-1.png",
"price": "15.00",
"brandid": "1",
"subcategoryid": "1",
"model": "model",
"subcategory": "Cat2",
"sku": "12",
"brand": "erer"
},
{
"fullsizeurl": "/uploads/incubout_denemeshop/1/product/4-sjy7xxyh-erer-qwert-1.png",
"productid": "4",
"price": "123.00",
"isactive": 1,
"brandid": "1",
"subcategoryid": "2",
"model": "qwert",
"isbundle": 0,
"subcategory": "Cat1",
"taxincluded": 0,
"brand": "erer",
"thumbnailsizeurl": "/uploads/incubout_denemeshop/1/product/4-sjy7xxyh-erer-qwert-1_thumb.png"
},
{
"productid": "2",
"price": "13.65",
"isactive": 1,
"brandid": "1",
"subcategoryid": "1",
"model": "yancı",
"isbundle": 0,
"subcategory": "Cat2",
"taxincluded": 0,
"brand": "erer"
}
]
这里是我的代码:
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<body ng-app="MyApp">
<div ng-controller="PostsCtrl">
<ul ng-repeat="post in posts">
<li>{{post.fullsizeurl}}</li>
</ul>
</div>
<script>
var app = angular.module("MyApp", []);
app.controller("PostsCtrl", function($scope, $http) {
$http.get('http://85.96.243.31/admin.productss/searchwithjson').
success(function(data, status, headers, config) {
$scope.posts = data;
}).
error(function(data, status, headers, config) {
// log error
});
});
</script>
</body>
</html>
我无法得到的产品fullsizeurls。这段代码有什么问题?
你正在运行脚本后ng-repeat ...也许多数民众赞成在问题 – Altoyyr
请检查控制台的错误...我疯狂的猜测是:违反SOP – devnull69
您是否启用服务JSON的计算机上的CORS? – Jack