Monday, 29 January 2018

HTTP Interceptors In Angular

Sending HTTP Headers to every request in Angular Let’s say we want to send 3 headers in http request : Content-Type, Accept and Accept-Language. To set headers for every request in Angular, we will create a class that implements HttpInterceptor. HttpInterceptor import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest}     from '@angular/common/http'; import {Injectable} from '@angular/core'; import {Observable} from 'rxjs'; @Injectable() export class CustomHttpInterceptorService implements HttpInterceptor {   intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {     request = request.clone({         headers: request.headers.set('Content-Type', 'application/json')     });     if (!request.headers.has('Accept')) {       request = request.clone({           headers: request.headers.set('Accept', 'application/json')         });     }     request = request.clone({ ...
Continue Reading →

PreLink, PostLink and Controller Methods of Angular Directives

PreLink, PostLink and Controller Methods of Angular Directives Link function of an Angular Directive As the name implicates, the link function has the duty of linking the model to the templates. Link function is the place where AngularJs does the data binding to the compiled templates. Let’s take a look at the signature of a link function. link: function LinkFn(scope, elem, attr, ctrl){} There...
Continue Reading →

Topics

ADFS (1) ADO .Net (1) Ajax (1) Angular (47) Angular Js (15) ASP .Net (14) Authentication (4) Azure (3) Breeze.js (1) C# (55) CD (1) CI (2) CloudComputing (2) Coding (10) CQRS (1) CSS (2) Design_Pattern (7) DevOps (4) DI (3) Dotnet (10) DotnetCore (20) Entity Framework (5) ExpressJS (4) Html (4) IIS (1) Javascript (17) Jquery (8) jwtToken (4) Lamda (3) Linq (10) microservice (4) Mongodb (1) MVC (46) NodeJS (8) React (10) SDLC (1) Sql Server (32) SSIS (3) SSO (1) TypeScript (3) UI (1) UnitTest (2) WCF (14) Web Api (16) Web Service (1) XMl (1)

Dotnet Guru Archives