Storing data in mobile storage


#1

how to store my data in mobile storage. this is my codes:

html:

Febuary

    <ion-item text-wrap *ngFor="let item of bethData">
        <ion-thumbnail item-left>
            <img src={{item.img}}>
        </ion-thumbnail>
        <h2>{{item.emp_name}}</h2>
        <p>{{item.emp_salary}}</p>
    </ion-item>
</ion-list>

ts:

import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import { Bethdata } from ‘…/…/…/providers/bethdata’;

@Component({
selector: ‘page-birthdays’,
templateUrl: ‘birthdays.html’,
providers: [Bethdata]
})
export class Birthdays {
bethData:any;

constructor(public navCtrl: NavController, public navParams: NavParams, public bethservice: Bethdata) {
this.getData();
}

ionViewDidLoad() {
console.log(‘ionViewDidLoad BirthdaysPage’);
}

getData(){
    this.bethservice.getRemoteData().subscribe(result => {
        this.bethData=result;
        console.log(this.bethData);
    },
    err =>{
        console.error(err);
    },
        () => console.log('getdata completed')
    );
}

}

and my providers .ts:

import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

@Injectable()
export class Bethdata {

constructor(public http: Http) {
console.log(‘Hello Bethdata Provider’);
}

getRemoteData(){
   return this.http.get('http://bethlehembulletin.comlu.com/emp.php').map(res => res.json())

}
}

tnx in advance guys…


#2

Have you looked at ionic-storage?