Search results for ""


Answer for How to set the headers for every request in Angular?

on October 17, 2020 πŸ”₯ 0 views

Add AuthInterceptor that will intercept all your HTTP requests and add the token to its headers: import { Injectable } from ‘@angular/core’; import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from ‘@angular/common/http’; import { Observable } from ‘rxjs’; @Injectable() export class AuthInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const token = localStorage.token; // […]

discussion

Answer for What is multicasting in angular and how to achieve multicasting?

on October 17, 2020 πŸ”₯ 0 views

Multi-casting is the practice of broadcasting to a list of multiple subscribers in a single execution. Let’s demonstrate the multi-casting feature, var source = Rx.Observable.from([1, 2, 3]); var subject = new Rx.Subject(); var multicasted = source.multicast(subject); // These are, under the hood, `subject.subscribe({…})`: multicasted.subscribe({ next: (v) => console.log(‘observerA: ‘ + v) }); multicasted.subscribe({ next: (v) […]

discussion

How to set the headers for every request in Angular?

on October 16, 2020 πŸ”₯ 0 views

How can I set the header in every request in angular? Let’s say I have token in localStorage and that needs to set for every REST API call.

discussion

What is multicasting in angular and how to achieve multicasting?

on October 16, 2020 πŸ”₯ 0 views

How to use multicast of Rxjs in angular? It will be great if you can explain with an example.

discussion

How to use AsyncPipe in Angular?

on October 6, 2020 πŸ”₯ 0 views

What is AsyncPipe in angular and how to use it? It will be great if someone can explain with an example.

discussion

Answer for How to use Wildcard route in Angular?

on October 5, 2020 πŸ”₯ 0 views

If the URL doesn’t match any predefined routes then it causes the router to throw an error and crash the app. In this case, you can use a wildcard route. A wildcard route has a path consisting of two asterisks to match every URL. For example, you can define PageNotFoundComponent for wildcard route as below: […]

discussion

How to use Wildcard route in Angular?

on October 5, 2020 πŸ”₯ 0 views

How to define wildcard route in angular? I have to show page not found component if the URL doesn’t match anything.

discussion

Answer for routerLinkActive always set home page link as active even if other page is active – Angular 10

on October 4, 2020 πŸ”₯ 0 views

I believe you need to use [routerLinkActiveOptions] in your template page. [routerLinkActiveOptions]=”{exact:true}” Set the above [routerLinkActiveOptions] directive to all navigation links, which will add the routerLinkActive class to only those navigation links which match the entire URL.

discussion

routerLinkActive always set home page link as active even if other page is active – Angular 10

on October 2, 2020 πŸ”₯ 0 views

I am using the angular 10 version I have an issue withΒ the routerLinkActive it is setting the home URL (base URL) to active even if the route is on another page. <li class=”nav-item”> <a class=”nav-link” [routerLink]='[“”]’ routerLinkActive=’active’>Home</a> </li> <li class=”nav-item”> <a class=”nav-link” [routerLink]='[“/contact-us”]’ routerLinkActive=’active’>Contact Us</a> </li>

discussion

Answer for Difference between an Annotation and a Decorator in Angular?

on October 1, 2020 πŸ”₯ 0 views

Annotations In Angular, annotations are used for creating an annotation array. They are only metadata sets of the class using the Reflect Metadata library. Decorators In Angular Decorators are design patterns used for separating decoration or modification of some class without changing the source code.

discussion