How to set and get json array into the local storage

How to set and get json array into the local storage.

Use Ionic Storage: https://ionicframework.com/docs/storage/

@Sujan12 Actually i want to do add to favorite .can i do that using ionic storage?.if possible please give me a example of code.i’m followed this app source code provided by ionic team in the git https://github.com/ionic-team/ionic-conference-app. I’m don’t understand the code.please help.

I have no idea what you are talking about. If you want to save a list of “favorites”, create a “favorites” object and put the IDs or objects of what you favorite in there, save it. Then yu can read it and check if the currently displayed item is in that list.

@Sujan12 Sir,please give me an example of code.i’m new in ionic .

https://github.com/ionic-team/ionic-conference-app/search?utf8=✓&q=favorite&type=

Hi @flycoders_sourav

Here is Example of local storage
app.module.ts file

import { IonicStorageModule } from '@ionic/storage';

// ...    

@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    // ...
  ],
  providers: []
})
export class AppModule {}

your component file

import { Storage } from '@ionic/storage';

export class MyApp {
  constructor(private storage: Storage) {

     // set a key/value
     this.storage.set('name', 'Max');

     // Or to get a key/value pair
     storage.get('age').then((val) => {
       console.log('Your age is', val);
     });
  }
}
nextbtn() {
  console.log(this.SignUpData.username);
  this.storage.set('username', this.SignUpData.username);
}
readUsername() {
  // Notice that the get method returns a promise!
  storage.get('username').then((username) => {
    console.log(username);
  });
}

Hope, this will solve your issue
Thanks,

@addwebsolution Actually i want to do add to favorite .can i do that using ionic storage?.if possible please give me a example of code.i’m followed this app source code provided by ionic team in the git https://github.com/ionic-team/ionic-conference-app. I’m don’t understand the code.please help.