1

I have having trouble with filtering my table with the below json object. It filters some of the key values, but doesnt work if my json is nested. I am sure i am doing something wrong and stupid.

heres a fiddle of the same. https://jsfiddle.net/pnypxhj8/1/

below is my JSON object:

[
 {
    "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": "[email protected]"
                    },
                    {
                        "Name": "Mary Nuts",
                        "Email": "[email protected]"
                    }
                ],
                "Comments": ""
            },
            "AdminApproval": {
                "Status": "Pending",
                "AdminDetails": [{
                        "Name": "Hardy Lee",
                        "Email": "[email protected]"
                    },
                    {
                        "Name": "Moss Grant",
                        "Email": "[email protected]"
                    }
                ],
                "Comments": ""
            },
            "RequestStatus": "Pending"
        },
        {
            "ProdName": "Note Book - Large",
            "ManagerApproval": {
                "Status": "Approved",
                "Approver": [{
                    "Name": "Jet Lee",
                    "Email": "[email protected]"
                }],
                "Comments": "Approved by Jet Lee"
            },

            "AdminApproval": {
                "Status": "Approved",
                "AdminDetails": [{
                        "Name": "Hardy Lee",
                        "Email": "[email protected]"
                    },
                    {
                        "Name": "Moss Grant",
                        "Email": "[email protected]"
                    }
                ],
                "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": "[email protected]"
                    }
                ],
                "Comments": ""
            },
            "AdminApproval": {
                "Status": "Approved",
                "AdminDetails": [{
                        "Name": "Hardy Lee",
                        "Email": "[email protected]"
                    },
                    {
                        "Name": "Moss Grant",
                        "Email": "[email protected]"
                    }
                ],
                "Comments": ""
            },
            "RequestStatus": "Approved"
        },
        {
            "ProdName": "Note Book - Large",
            "ManagerApproval": {
                "Status": "Approved",
                "Approver": [{
                    "Name": "Jet Lee",
                    "Email": "[email protected]"
                }],
                "Comments": "Approved by Jet Lee"
            },

            "AdminApproval": {
                "Status": "Approved",
                "AdminDetails": [{
                        "Name": "Hardy Lee",
                        "Email": "[email protected]"
                    },
                    {
                        "Name": "Moss Grant",
                        "Email": "[email protected]"
                    }
                ],
                "Comments": ""
            },
            "RequestStatus": "Completed"
        }
    ]
}

]

3
  • 2
    Can you explain which data is not getting mapped and what you actually wanna achieve? Commented May 25, 2017 at 8:12
  • the data is getting mapped.. but its not getting filtered "Status": "Approved", //----> But Doesnt works on this Commented May 25, 2017 at 9:04
  • @nipiv if the answer is correct, could you mark as accepted? Commented May 29, 2017 at 6:54

1 Answer 1

2

First: you have a typo on the object properties. You have ManagerApproval on filter but has ManagersApproval (with S) properties among your data.

Second: the filter should be ng-repeat="a in data.ProdRequest | filter:{ProdName: prodName, ManagerApproval: { Status: managerApproval }}"

here's the working fiddle: https://jsfiddle.net/pnypxhj8/3/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.