当我使用local:storage
变量时出现此错误。
我只想注意到它只是在一小时之前发生的。在此之前它运作良好。
当我尝试通过" ionic serve"运行应用程序时显示此错误。
这是我的服务
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())
}
}
答案 0 :(得分:2)
这是因为您还将本地声明为public local:Storage;
,并且在构造函数中也声明为私有,如下所示:
constructor(public http: Http,private local: Storage,private navCtrl:NavController) {
删除public local:Storage;
答案 1 :(得分:1)
我改变了它,但我从中得到了新的错误返回类型的公共方法 导出的类具有或正在使用名称' observable' ...
为了解决该问题,您需要显式导入Observable
类:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { Observable } from "rxjs/Observable"; // <- add this import
import {NavController} from "ionic-angular";