How to filter data using angular 4 route params

310 views Asked by At

Can anybody please explain how I can use Angular (4) route params to filter a JSON object to only return 1 record (so I only want to show more specific details, bit like an admin panel). All the examples I've seen just seem to show you how to console.log the param id from the url and don't really go much further (or if they do it isn't explained as clearly as I would like). What I want to do is I have a JSON object say

    {id: 1, name:"Dave"}, {id:2, name: "Steve"} 

How can I use the route param in a service to show only the name based upon the id I pass in the url?

    name/1 

So this example would give me access to the first set of records.

Thanks

0

There are 0 answers