我只是创建一个这样的示例对象。我想使用angular来获取具有值的特定键。例如,我只想要available_name值。请帮我解决这个问题。
[{"row":1,"position":"A","available":true},{"row":1,"data":"B","available":false},{"coloumn":1,"position":"C","booked":false},{"coloumn":1,"position":"D","bookeddate":false},{"row":2,"position":"A","name":true},{"row":2,"position":"B","available":false},{"row":2,"position":"C","available":false},{"row":2,"name":"D","availablename":false},{"row":3,"availableposition":"A","available_name":true},{"row":3,"position":"B","available":false},{"row":3,"position":"C","available":false},{"row":3,"coloumn1":"D","availablecoloumn":false}]
答案 0 :(得分:0)
这是您提出的纯粹的JavaScript。
var obj = [{
"row": 1,
"position": "A",
"available": true
}, {
"row": 1,
"data": "B",
"available": false
}, {
"coloumn": 1,
"position": "C",
"booked": false
}, {
"coloumn": 1,
"position": "D",
"bookeddate": false
}, {
"row": 2,
"position": "A",
"name": true
}, {
"row": 2,
"position": "B",
"available": false
}, {
"row": 2,
"position": "C",
"available": false
}, {
"row": 2,
"name": "D",
"availablename": false
}, {
"row": 3,
"availableposition": "A",
"available_name": true
}, {
"row": 3,
"position": "B",
"available": false
}, {
"row": 3,
"position": "C",
"available": false
}, {
"row": 3,
"coloumn1": "D",
"availablecoloumn": false
}]
console.log(obj[i].available_name)
In your case "i" is 8.