Adir Zoari Adir Zoari - 2 months ago 7
TypeScript Question

All declarations of ‘local' must have identical modifers in ionic 2

I get this error when i use with

local:storage
variable.
I just want to notice that's it's just happened before an hour. Before that it worked well.

this error shown when I try to run the app by "ionic serve".
error

This is my service

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import {NavController} from "ionic-angular";

import { Storage } from '@ionic/storage';
/*
Generated class for the Myservice provider.

See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class MyService {

public local:Storage;
public getsession: any;


constructor(public http: Http,private local: Storage,private navCtrl:NavController) {
this.local=new Storage();

}
postLogin(data){
let link = "http://adirzoari.16mb.com/login.php";
return this.http.post(link,data)
.map(res => res.json())
}
checkToken(){
return this.getsession =this.local.get('token');

}
getData(){
let link = "http://adirzoari.16mb.com/selectNotes.php";
return this.http.get(link)
.map(res=>res.json())
}
postInsert(data){
let link="";
return this.http.post(link,data)
.map(res=>res.json())
}
postUpdate(data){
let link="";
return this.http.post(link,data)
.map(res=>res.json())
}
postDelete(data){
let link = "http://adirzoari.16mb.com/deleteNotes.php";
return this.http.post(link,data)
.map(res => res.json())
}
}


in addition,
i get this error
new error

Answer

This is because you also have local declared as public local:Storage; and also in the constructor as private as shown below:

constructor(public http: Http,private local: Storage,private navCtrl:NavController) {

Fix

Delete public local:Storage;