angular – 如何在ionic2中传递数据

前端之家收集整理的这篇文章主要介绍了angular – 如何在ionic2中传递数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我通过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");
 }

猜你在找的Angularjs相关文章