如何使用angularjs获取特定的对象键

时间:2020-11-29 23:46:53

I just create an example object like this. I want to take specific key with value using angular. Ex i want available_name value only. Please help me solve this issue.

我只是创建一个这样的示例对象。我想使用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}]

1 个解决方案

#1


This is pure javascript which you have asked.

这是你问的纯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.

#1


This is pure javascript which you have asked.

这是你问的纯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.