I was recently working on the angular 2 custom pipe. I created couple of custom pipe to serve different purpose. So I thought it will be useful for others, because I think this is very common for most of us
- Age PIPE
- Full Address PIPE
1. Age Pipe
Age pipe is very simple if you give date of birth of user. It will convert to age in years using moment js.
Example : {{ ‘1988-10-31’ | age }}
2. Full Address PIPE
In most cases, We will store address in database as separate fields, but when it comes to visualization in app, we need to display as full raw address from object. So this pipe will help us to transform object to raw address.
Example : {{ addressObject | fullAddress}}
Thanks, hope it helps someone