Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng repeat中的目标嵌套数组_Javascript_Json_Angularjs_Angularjs Ng Repeat - Fatal编程技术网

Javascript ng repeat中的目标嵌套数组

Javascript ng repeat中的目标嵌套数组,javascript,json,angularjs,angularjs-ng-repeat,Javascript,Json,Angularjs,Angularjs Ng Repeat,有人能告诉我我做错了什么吗 我正在检索一些数据并将其作为“productInfo”注入控制器 我可以很好地加载数据,但当我想在ng重复中以特定值为目标时,我没有得到期望的结果。我得到的最好的数据是最后一组JSON数据 我正在从服务器获取JSON,如果需要,可以更改格式。我刚从Angular开始,如果有一个简单的答案,我很抱歉 HTML: 谢谢json上的items属性不是数组,因此您无法对其进行迭代 所需的格式应如下所示: { "description":"Lorem Ipsum",

有人能告诉我我做错了什么吗

我正在检索一些数据并将其作为“productInfo”注入控制器

我可以很好地加载数据,但当我想在ng重复中以特定值为目标时,我没有得到期望的结果。我得到的最好的数据是最后一组JSON数据

我正在从服务器获取JSON,如果需要,可以更改格式。我刚从Angular开始,如果有一个简单的答案,我很抱歉

HTML:


谢谢

json上的
items
属性不是数组,因此您无法对其进行迭代

所需的格式应如下所示:

{
    "description":"Lorem Ipsum",
    "headline":"Promotion headline",
    "items":[
        {
            "img":"http://placehold.it/303x152",
            "title":"Standard Product 1"
        },
        {
            "img":"http://placehold.it/303x152",
            "title":"Standard Product 2"
        },
        {
            "img":"http://placehold.it/303x152",
            "title":"Standard Product 3"
        }
    ]
}

您在
项中有相同的键。密钥必须是唯一的:

"items":{
    "Standard":{
        ..
    },
    "Standard":{
        ..
    },
    "Standard":{
        ..
    }
}
应该是

"items":{
    "Standard1":{
        ..
    },
    "Standard2":{
        ..
    },
    "Standard3":{
        ..
    }
}

您的观点是正确的,但它不能使
ngRepeat
工作,因为
项目
不是一个数组。我明白了,ng repeat=“item in items”是否会在项目数组中循环?@Paul正是这样。你可以看到一把正在工作的小提琴。这太棒了,这正是我所需要的——我将阅读更多关于数组结构的内容。这是来自第三方,所以我会要求修改。
"items":{
    "Standard":{
        ..
    },
    "Standard":{
        ..
    },
    "Standard":{
        ..
    }
}
"items":{
    "Standard1":{
        ..
    },
    "Standard2":{
        ..
    },
    "Standard3":{
        ..
    }
}