我在使用下面的json对象过滤我的表时遇到了问题。 它会过滤一些键值,但如果我的json是嵌套的,它就不起作用。 我确信我做错了什么都是愚蠢的。
这是一个相同的小提琴。 https://jsfiddle.net/pnypxhj8/1/ 下面的是我的JSON对象:
[
{
"EmpId": "3901", //----> Filter works on this
"SubmitDate": "30/04/2017", //----> Filter works on this
"Employee": "John", //----> Filter works on this
"ProdRequest": [{
"ProdName": "Mac Air laptop - Apple",
"ManagersApproval": {
"Status": "Approved", //----> But Doesnt works on this
"ManagersDetails": [{
"Name": "Steve Rock",
"Email": "steve.rock@test.com"
},
{
"Name": "Mary Nuts",
"Email": "mary.nuts@test.com"
}
],
"Comments": ""
},
"AdminApproval": {
"Status": "Pending",
"AdminDetails": [{
"Name": "Hardy Lee",
"Email": "Hardy.Lee@test.com"
},
{
"Name": "Moss Grant",
"Email": "Moss.Grant@test.com"
}
],
"Comments": ""
},
"RequestStatus": "Pending"
},
{
"ProdName": "Note Book - Large",
"ManagerApproval": {
"Status": "Approved",
"Approver": [{
"Name": "Jet Lee",
"Email": "jet.lee@test.com"
}],
"Comments": "Approved by Jet Lee"
},
"AdminApproval": {
"Status": "Approved",
"AdminDetails": [{
"Name": "Hardy Lee",
"Email": "Hardy.Lee@test.com"
},
{
"Name": "Moss Grant",
"Email": "Moss.Grant@test.com"
}
],
"Comments": ""
},
"RequestStatus": "Completed"
}
]
},
{
"EmpId": "550",
"SubmitDate": "22/04/2017",
"Employee": "Mary Kom",
"ProdRequest": [{
"ProdName": "Seagate Harddisk 500TB",
"ManagersApproval": {
"Status": "Approved",
"ManagersDetails": [{
"Name": "Steve Rock",
"Email": "steve.rock@test.com"
}
],
"Comments": ""
},
"AdminApproval": {
"Status": "Approved",
"AdminDetails": [{
"Name": "Hardy Lee",
"Email": "Hardy.Lee@test.com"
},
{
"Name": "Moss Grant",
"Email": "Moss.Grant@test.com"
}
],
"Comments": ""
},
"RequestStatus": "Approved"
},
{
"ProdName": "Note Book - Large",
"ManagerApproval": {
"Status": "Approved",
"Approver": [{
"Name": "Jet Lee",
"Email": "jet.lee@test.com"
}],
"Comments": "Approved by Jet Lee"
},
"AdminApproval": {
"Status": "Approved",
"AdminDetails": [{
"Name": "Hardy Lee",
"Email": "Hardy.Lee@test.com"
},
{
"Name": "Moss Grant",
"Email": "Moss.Grant@test.com"
}
],
"Comments": ""
},
"RequestStatus": "Completed"
}
]
}
答案 0 :(得分:2)
首先:你有一个关于对象属性的拼写错误。您在过滤器上有ManagerApproval
但在数据中有ManagersApproval
(带S)属性。
第二:过滤器应为ng-repeat="a in data.ProdRequest | filter:{ProdName: prodName, ManagerApproval: { Status: managerApproval }}"
这是工作小提琴:https://jsfiddle.net/pnypxhj8/3/