ionic3 Injectable 引入NavController

在service里 引入 navcontroller 报错

And I ``get error No provider ``for NavController.

一个比较容易解决的方法,

import {IonicApp, LoadingController, ToastController, Loading, NavController, App} ``from 'ionic-angular'``;

constructor(``private http: Http,

private storageService:StorageService,

public toastCtrl :ToastController,``public loadingCtr:LoadingController,

public appCtrl: App,

) {

console.log(``'Hello HttpRequestService Provider'``);

}

if (error.status == 500) {

if``(JSON.parse(error._body).ret_code== ``"98" || JSON.parse(error._body).ret_code== ``"99" ){

msg = ``'token失效,请重新登录!'``;

let activeNav: NavController = ``this``.appCtrl.getActiveNav();

console.log(activeNav)

activeNav.push(``"LoginPage"``);

}``else {

msg = ``'网络连接错误'``;

}

console.error(msg+``',请检查网络是否连接'``);

}

|

这是一种比较有效的替代方式,

你可能感兴趣的:(ionic3 Injectable 引入NavController)