Shared Preferance in Angular.

Hello All,

Basicaly shared preferance's are like they will get assigned the value until it get reset or changed to another,

In angular we use components which is help us to maintain the website but to make shared preference we just has to create an another by using below code,

ng g m shared --routing

then we will get 2 files named:

1: shared.service.spec.ts and 2: shared.service.ts

Where 1st is self created and no need anychanges in that...

in 2nd file wqe have to create function or methods which is used to get data shared like below...

 getIncidentId(){ 
//Action that we want to make when this method is called 
}

We has to import this shared file into our component and then get value...

import { SharedService } from '../shared/shared.service';
constructor(private shared:SharedService)
{
   this.shared.getIncidentId()
  }

As above thank you...

Sign In or Register to comment.