Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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 如何使用java脚本或angular js将动态json数据绑定到html_Javascript_Angularjs - Fatal编程技术网

Javascript 如何使用java脚本或angular js将动态json数据绑定到html

Javascript 如何使用java脚本或angular js将动态json数据绑定到html,javascript,angularjs,Javascript,Angularjs,我有Json数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到html json: 我有Json数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到html java脚本: for (var prop in ProductProperties) { alert(prop); } 试试这个 var arr={ "ProductIdProperties": [ { "product

我有Json数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到html

json:

我有Json数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到html java脚本:

for (var prop in ProductProperties)
    {
    alert(prop);
    }    
试试这个

var arr={
    "ProductIdProperties": [
        {
            "productId": "890e5b4ceb9842c9bd8d8a01094b1e5f",
            "ProductKeys": [
                ".Not Covered in Warranty",
                ".Warranty Summary",
                "Machine Dimensions.Color",
                "Machine Dimensions.Dimension",
                "Machine Dimensions.Weight",
                "Ports/Slots.Other Ports",
                "Ports/Slots.Multi Card Slot",
                "Ports/Slots.VGA Port",
                "Ports/Slots.HDMI Port",
                "Ports/Slots.RJ45 LAN",
                "Ports/Slots.Mic In",
                "Ports/Slots.USB Port",
                "Power.Battery Cell",
                "Power.Power Supply",
                "Power.Battery Backup",
                "Communication.Bluetooth",
                "Communication.Wireless LAN",
                "Communication.Ethernet",
                "Audio.Sound",
                "Audio.Speakers",
                "Audio.Internal Mic",
                "Input.Keyboard",
                "Input.Pointer Device",
                "Input.Web Camera",
                "Graphics.Graphic Processor",
                "Display.Screen Type",
                "Display.Resolution",
                "Display.Screen Size",
                "Platform.System Architecture",
                "Platform.Operating System",
                "Optical Disk Drive.Optical Drive",
                "Optical Disk Drive.Read/Write Speed",
                "Storage.HDD Capacity",
                "Storage.RPM",
                "Storage.Hardware Interface",
                "Memory.System Memory",
                "Memory.Memory Slots",
                "Memory.Expandable Memory",
                "Processor.Cache",
                "Processor.Clock Speed",
                "Processor.Brand",
                "Processor.Chipset",
                "Processor.Variant",
                "Processor.Processor",
                "General1.Model ID",
                "General1.Lifestyle",
                "General1.Model Name",
                "General1.Brand",
                "In the Box.Sales Package"
            ],
            "imageUrls": [
                "/images/Chrysanthemum.jpg"
            ],
            "ProductProperties": {
                "Sales Package": [
                    "Laptop",
                    "User Guide and Manuals"
                ],
                "General1": {
                    "Brand": "ssssssssssssss",
                    "Model Name": "aaaaaaaaaaaaaaaaaa",
                    "Lifestyle": "aaaaaaaaaaaaaaaaaa",
                    "Model ID": "rrrrrrrrrrrrrrrrrrrrr"
                },
                "Processor": {
                    "Processor": "hjj",
                    "Variant": "khj",
                    "Chipset": "khjhj",
                    "Brand": "hjh",
                    "Clock Speed": "kj",
                    "Cache": "jh"
                },
                "Memory": {
                    "Expandable Memory": "jkh",
                    "Memory Slots": "hj",
                    "System Memory": "hj"
                },
                "Storage": {
                    "Hardware Interface": "h",
                    "RPM": "jh",
                    "HDD Capacity": "jh"
                },
                "Optical Disk Drive": {
                    "Read/Write Speed": "jh",
                    "Optical Drive": "jh"
                },
                "Platform": {
                    "Operating System": "jkhkj",
                    "System Architecture": "hkj"
                },
                "Display": {
                    "Screen Size": "hkj",
                    "Resolution": "hjh",
                    "Screen Type": "h"
                },
                "Graphic Processor": "kj",
                "Input": {
                    "Web Camera": "kj",
                    "Pointer Device": "hkjh",
                    "Keyboard": "h"
                },
                "Audio": {
                    "Internal Mic": "hkj",
                    "Speakers": "hj",
                    "Sound": "hh"
                },
                "Communication": {
                    "Ethernet": "j",
                    "Wireless LAN": "hj",
                    "Bluetooth": "h"
                },
                "Power": {
                    "Battery Backup": "hh",
                    "Power Supply": "h",
                    "Battery Cell": "h"
                },
                "Ports/Slots": {
                    "USB Port": "hh",
                    "Mic In": "Yes",
                    "RJ45 LAN": "Yes",
                    "HDMI Port": "Yes",
                    "VGA Port": "Yes",
                    "Multi Card Slot": "mmmmmmmmmmm",
                    "Other Ports": [
                        "Headphone Jack ",
                        "Audio Jack"
                    ]
                },
                "Machine Dimensions": {
                    "Weight": "1111111",
                    "Dimension": "2222222",
                    "Color": "3333333333"
                },
                "": {
                    "Warranty Summary": "44444444444",
                    "Not Covered in Warranty": "5555555555555"
                }
            }
        }
    ]
}
var k=arr.ProductIdProperties
for(var i in k)
{
 var ke=(k[i].ProductKeys );  
    for(var j in ke)
    {
        console.log(ke[j]);
    }
}

值必须与产品属性(即“ProductKeys”)匹配并绑定:[“Machine Dimensions.Color”]与“ProductProperties”:{“Machine Dimensions”:{“Weight”:“1111111”,“Dimension”:“2222222”,“Color”:“3333”},结果将为3333
var arr={
    "ProductIdProperties": [
        {
            "productId": "890e5b4ceb9842c9bd8d8a01094b1e5f",
            "ProductKeys": [
                ".Not Covered in Warranty",
                ".Warranty Summary",
                "Machine Dimensions.Color",
                "Machine Dimensions.Dimension",
                "Machine Dimensions.Weight",
                "Ports/Slots.Other Ports",
                "Ports/Slots.Multi Card Slot",
                "Ports/Slots.VGA Port",
                "Ports/Slots.HDMI Port",
                "Ports/Slots.RJ45 LAN",
                "Ports/Slots.Mic In",
                "Ports/Slots.USB Port",
                "Power.Battery Cell",
                "Power.Power Supply",
                "Power.Battery Backup",
                "Communication.Bluetooth",
                "Communication.Wireless LAN",
                "Communication.Ethernet",
                "Audio.Sound",
                "Audio.Speakers",
                "Audio.Internal Mic",
                "Input.Keyboard",
                "Input.Pointer Device",
                "Input.Web Camera",
                "Graphics.Graphic Processor",
                "Display.Screen Type",
                "Display.Resolution",
                "Display.Screen Size",
                "Platform.System Architecture",
                "Platform.Operating System",
                "Optical Disk Drive.Optical Drive",
                "Optical Disk Drive.Read/Write Speed",
                "Storage.HDD Capacity",
                "Storage.RPM",
                "Storage.Hardware Interface",
                "Memory.System Memory",
                "Memory.Memory Slots",
                "Memory.Expandable Memory",
                "Processor.Cache",
                "Processor.Clock Speed",
                "Processor.Brand",
                "Processor.Chipset",
                "Processor.Variant",
                "Processor.Processor",
                "General1.Model ID",
                "General1.Lifestyle",
                "General1.Model Name",
                "General1.Brand",
                "In the Box.Sales Package"
            ],
            "imageUrls": [
                "/images/Chrysanthemum.jpg"
            ],
            "ProductProperties": {
                "Sales Package": [
                    "Laptop",
                    "User Guide and Manuals"
                ],
                "General1": {
                    "Brand": "ssssssssssssss",
                    "Model Name": "aaaaaaaaaaaaaaaaaa",
                    "Lifestyle": "aaaaaaaaaaaaaaaaaa",
                    "Model ID": "rrrrrrrrrrrrrrrrrrrrr"
                },
                "Processor": {
                    "Processor": "hjj",
                    "Variant": "khj",
                    "Chipset": "khjhj",
                    "Brand": "hjh",
                    "Clock Speed": "kj",
                    "Cache": "jh"
                },
                "Memory": {
                    "Expandable Memory": "jkh",
                    "Memory Slots": "hj",
                    "System Memory": "hj"
                },
                "Storage": {
                    "Hardware Interface": "h",
                    "RPM": "jh",
                    "HDD Capacity": "jh"
                },
                "Optical Disk Drive": {
                    "Read/Write Speed": "jh",
                    "Optical Drive": "jh"
                },
                "Platform": {
                    "Operating System": "jkhkj",
                    "System Architecture": "hkj"
                },
                "Display": {
                    "Screen Size": "hkj",
                    "Resolution": "hjh",
                    "Screen Type": "h"
                },
                "Graphic Processor": "kj",
                "Input": {
                    "Web Camera": "kj",
                    "Pointer Device": "hkjh",
                    "Keyboard": "h"
                },
                "Audio": {
                    "Internal Mic": "hkj",
                    "Speakers": "hj",
                    "Sound": "hh"
                },
                "Communication": {
                    "Ethernet": "j",
                    "Wireless LAN": "hj",
                    "Bluetooth": "h"
                },
                "Power": {
                    "Battery Backup": "hh",
                    "Power Supply": "h",
                    "Battery Cell": "h"
                },
                "Ports/Slots": {
                    "USB Port": "hh",
                    "Mic In": "Yes",
                    "RJ45 LAN": "Yes",
                    "HDMI Port": "Yes",
                    "VGA Port": "Yes",
                    "Multi Card Slot": "mmmmmmmmmmm",
                    "Other Ports": [
                        "Headphone Jack ",
                        "Audio Jack"
                    ]
                },
                "Machine Dimensions": {
                    "Weight": "1111111",
                    "Dimension": "2222222",
                    "Color": "3333333333"
                },
                "": {
                    "Warranty Summary": "44444444444",
                    "Not Covered in Warranty": "5555555555555"
                }
            }
        }
    ]
}
var k=arr.ProductIdProperties
for(var i in k)
{
 var ke=(k[i].ProductKeys );  
    for(var j in ke)
    {
        console.log(ke[j]);
    }
}