Angular — Useful Code Snippets
This article contains some useful Angular code snippets. Given below is a table of contents for this article:
1. A Development Only Directive
You can use this directive on your component template elements to remove that specific code in the production build. This is helpful if you want to avoid commenting your code before production build and while the component is in active development.
2. Executing Parallel API Requests
Suppose we have an API endpoint for getting messages, and we want to get a list of messages by their IDs in parallel requests, we can use the following code for that:
3. Display * in Place of a Value
We can create a pipe
e.g. password
and apply that on a value where we want to display * or any other character instead of the actual value. The benefit of the pipe is that we'll be able to use it in our entire app and a change in single file will be reflected in all the places where the pipe is used.
If you find this post useful, then show some love by clapping 👏 ❤️ You can follow me on Twitter 👇
Checkout my StackOverflow profile 👇