简单介绍一下跳转页面,和页面传值
- 引入
import { NavController, NavParams } from 'ionic-angular';
constructor(
public navCtrl: NavController,
public params: NavParams,
) {}
- 页面跳转并传值
//引入要跳转的组件
import {detailComponent} from '../detail/detail.component';
//跳转方法
goToDetail(Code: string, Company? : string) {
this.navCtrl.push(detailComponent, {
code: Code,
company: Company
});
}
//页面接收
let code = this.params.get("code");
let company = this.params.get("company");
- 返回上一页
goBack(){
this.navCtrl.pop();
}
- 请求接口失败或者成功返回页面
this.navCtrl.setRoot(listComponent);
如果需要返回是传入值
this.navCtrl.setRoot(listComponent,{
from: fromlist;
});
网友评论