美文网首页Ionic-
2018-02-26-Ionic-导航页面跳转

2018-02-26-Ionic-导航页面跳转

作者: xiaojianxu | 来源:发表于2018-02-26 16:23 被阅读32次

    Navigating to Pages

    export class ListPage {
     
      ....
      itemTapped(event, item) {
           this.navCtrl.push(ItemDetailsPage, {
              item: item
            });
      }
    }
    

    上面引用的 ItemDetailsPage,需要引入:

    import {ItemDetailsPage} from '../pages/item-details/item-details';
    

    完整的代码如下:

    import { Component } from '@angular/core';
    
    import { NavController, NavParams } from 'ionic-angular';
    
    import { ItemDetailsPage } from '../item-details/item-details';
    
    @Component({
      selector: 'page-list',
      templateUrl: 'list.html'
    })
    export class ListPage {
      icons: string[];
      items: Array<{title: string, note: string, icon: string}>;
    
      constructor(public navCtrl: NavController, public navParams: NavParams) {
        this.icons = ['flask', 'wifi', 'beer', 'football', 'basketball', 'paper-plane',
        'american-football', 'boat', 'bluetooth', 'build'];
    
        this.items = [];
        for(let i = 1; i < 11; i++) {
          this.items.push({
            title: 'Item ' + i,
            note: 'This is item #' + i,
            icon: this.icons[Math.floor(Math.random() * this.icons.length)]
          });
        }
      }
    
      itemTapped(event, item) {
        this.navCtrl.push(ItemDetailsPage, {
          item: item
        });
      }
    }
    
    

    相关文章

      网友评论

        本文标题:2018-02-26-Ionic-导航页面跳转

        本文链接:https://www.haomeiwen.com/subject/pqmyxftx.html