加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 如何在ionic2中传递数据

发布时间:2020-12-17 17:54:08 所属栏目:安全 来源:网络整理
导读:我通过http获取数据.我想将数据传递给PlacesListPage.我的数据中有“id,name,category,…”.我想在PlacesListPage中使用theese,如下所示:{{xxx.id}},{{xxx.name}} …请帮帮我… xxx – 例如) import {Page,NavController,NavParams} from 'ionic-angular';i
我通过http获取数据.我想将数据传递给PlacesListPage.我的数据中有“id,name,category,…”.我想在PlacesListPage中使用theese,如下所示:{{xxx.id}},{{xxx.name}} …请帮帮我…
xxx – 例如)

import {Page,NavController,NavParams} from 'ionic-angular';
import {Http} from 'angular2/http';
import 'rxjs/Rx';
import {PlacesListPage} from '../places-list/places-list';
/*enter code here
  Generated class for the PlacesPage page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Page({
  templateUrl: 'build/pages/places/places.html',})
export class PlacesPage {
  static get parameters() {
    return [[NavController],[Http],[NavParams]];
  }


  constructor(nav,http,navParams) {
    this.nav = nav;
    this.http = http.get('https://api.myjson.com/bins/2ud24').map(res => res.json()).subscribe(
        (data) => {
          this.data = data;
        });

}

解决方法

您也可以使用此方法:

let something = { test: 1 };
this.nav.push(existingPaymentModal,{something});

然后

constructor(private navParams: NavParams) {
        this.something = this.navParams.get("something");
 }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读