Posts

Showing posts from 2022

Nested API's in Angular

Hi Friends, This is Lakshman here. As part of the Series Angular Best Practices Today, We will Nested API's in Angular . Pre-requisites: The pre-requisites are Node.JS - Click Here Angular CLI - Click Here VS Code - Click Here Nested API's It is a Concept where we may call multiple API at one time or Chaining the API to Call one by one with passing data. The mainly used functions to implement Nested API from rxjs library, forkJoin mergeMap forkJoin It used to call multiple APIs to fetch all data as an array at one time. For example, return forkJoin ([ this . helloService . getData () , this . helloService . getStatus () ]) . pipe ( map (allResponses => { return { Data : allResponses[allResponses . length - 2 ] , Status : allResponses[allResponses . length - 1 ] } ; }) ) ; mergeMap It uses to chain the

Pipes In Angular

Hi Friends, This is Lakshman here. As part of the Series “Angular Best Practices”. Today, We will Pipes in Angular . Pre-requisites: The pre-requisites are Node.JS - Click Here Angular CLI - Click Here VS Code - Click Here Pipes It is a feature used to transform data and display it on UI. We can categorise with two options as below, Pre-defined Pipes. Custom Pipes. In Pipe, it needs to create with Model of it uses only to that Module else add to Shared Module to access it. Some Pre-defined Pipes are Datapipe PercentagePipe Decimal Pipe, etc., In regards to Custom Pipes, we create and use them. For example, To Create it, import { Pipe , PipeTransform } from '@angular/core' ; @ Pipe ({ name : 'status' }) export class StatusPipe implements PipeTransform { transform (value : unknown , ... args : unknown []) : unknown { return value ? "Completed" : "Yet To Complete" ; }