pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<legend id='8kFJm'><style id='8kFJm'><dir id='8kFJm'><q id='8kFJm'></q></dir></style></legend>

    1. <small id='8kFJm'></small><noframes id='8kFJm'>

      1. <tfoot id='8kFJm'></tfoot>
        <i id='8kFJm'><tr id='8kFJm'><dt id='8kFJm'><q id='8kFJm'><span id='8kFJm'><b id='8kFJm'><form id='8kFJm'><ins id='8kFJm'></ins><ul id='8kFJm'></ul><sub id='8kFJm'></sub></form><legend id='8kFJm'></legend><bdo id='8kFJm'><pre id='8kFJm'><center id='8kFJm'></center></pre></bdo></b><th id='8kFJm'></th></span></q></dt></tr></i><div class="y22uw2c" id='8kFJm'><tfoot id='8kFJm'></tfoot><dl id='8kFJm'><fieldset id='8kFJm'></fieldset></dl></div>
          <bdo id='8kFJm'></bdo><ul id='8kFJm'></ul>
      2. 如何在 Ionic 中的選項卡之間傳遞數據

        How to pass data between tabs in Ionic(如何在 Ionic 中的選項卡之間傳遞數據)
          <tbody id='fddwp'></tbody>
        <legend id='fddwp'><style id='fddwp'><dir id='fddwp'><q id='fddwp'></q></dir></style></legend>

          <bdo id='fddwp'></bdo><ul id='fddwp'></ul>
        • <i id='fddwp'><tr id='fddwp'><dt id='fddwp'><q id='fddwp'><span id='fddwp'><b id='fddwp'><form id='fddwp'><ins id='fddwp'></ins><ul id='fddwp'></ul><sub id='fddwp'></sub></form><legend id='fddwp'></legend><bdo id='fddwp'><pre id='fddwp'><center id='fddwp'></center></pre></bdo></b><th id='fddwp'></th></span></q></dt></tr></i><div class="a0s2qa2" id='fddwp'><tfoot id='fddwp'></tfoot><dl id='fddwp'><fieldset id='fddwp'></fieldset></dl></div>
        • <tfoot id='fddwp'></tfoot>

            <small id='fddwp'></small><noframes id='fddwp'>

                1. 本文介紹了如何在 Ionic 中的選項卡之間傳遞數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個帶有 3 個選項卡的簡單項目.當用戶點擊第一個選項卡上某個項目的按鈕時,我需要該項目移動到第二個選項卡,反之亦然.(發生這種情況時,我還需要通知服務器).有什么方法可以讓我將項目對象傳遞給 About-Page 選項卡中的數組,反之亦然?

                  I have a simple project with 3 tabs. When the user hits a button on an item on the first tab I need that item to move to the second tab and vise versa. (I also need to notify a server when this happens). Is there any way for me to pass a item object to a array in the About-Page tab and vise versa?

                  home.html

                  <ion-header>
                    <ion-toolbar>
                      <ion-title>Home</ion-title>
                      <ion-buttons end>
                        <button ion-button icon-only color="royal" (click)="updateData()">
                          <ion-icon name="refresh"></ion-icon>
                        </button>
                      </ion-buttons>
                    </ion-toolbar>
                  </ion-header>
                  
                  <ion-content>
                    <ion-list>
                      <ion-item-sliding *ngFor="let item of items">
                        <ion-item>
                          <ion-icon name="alert" *ngIf="!item.taken" item-left></ion-icon>
                          <ion-icon name="checkmark-circle-outline" *ngIf="item.taken" item-left></ion-icon>
                          <h2><b>{{item.title}}</b></h2>
                          <h3>{{item.name}} | {{item.number}}</h3>
                          <h3 style="white-space: normal;"><b>Details:</b> {{item.text}}</h3>
                        </ion-item>
                        <ion-item-options side="left">
                          <button ion-button color="primary" (click)="smsPressed(item)">
                            <ion-icon name="text"></ion-icon>
                            Text
                          </button>
                          <button ion-button color="secondary" (click)="phonePressed(item)">
                            <ion-icon name="call"></ion-icon>
                            Call
                          </button>
                        </ion-item-options>
                        <ion-item-options side="right">
                          <button ion-button color="primary" *ngIf="item.taken" (click)="responderPressed(item)">
                            <ion-icon name="person"></ion-icon>
                            Responder
                          </button>
                          <button ion-button color="primary" *ngIf="!item.taken" (click)="takecallPressed(item)">
                            <ion-icon name="navigate"></ion-icon>
                            Take Call
                          </button>
                        </ion-item-options>
                      </ion-item-sliding>
                    </ion-list>
                  
                    <ion-fab right bottom>
                      <button ion-fab color="light" (click)="addItem()"><ion-icon name="add"></ion-icon></button>
                    </ion-fab>
                  </ion-content>
                  

                  home.ts

                  import { Component } from '@angular/core';
                  import { NavController } from 'ionic-angular';
                  import { AlertController } from 'ionic-angular';
                  
                  @Component({
                    selector: 'page-home',
                    templateUrl: 'home.html'
                  })
                  export class HomePage {
                    items: any[];
                  
                    constructor(public navCtrl: NavController, public alertCtrl: AlertController) {
                      this.items = []
                        this.items.push({
                          title: "Title",
                          text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium quam at est porta fringilla.",
                          name: "Sam",
                          number: "(555) 555-5555",
                          taken: true,
                          responder: {
                            name: "Bob",
                            phone: "(666) 666-6666"
                          }
                        })
                        this.items.push({
                          title: "Stuff",
                          text: "Take Now",
                          name: "Sam",
                          number: "(555) 555-5555",
                          taken: false,
                          responder: {}
                        })
                  
                    }
                  
                    buttonPressed(item){
                      alert(item.title)
                    }
                  
                    smsPressed(item){alert(item.number)}
                  
                    phonePressed(item){alert(item.number)}
                  
                    responderPressed(item){alert(item.responder.name)}
                  
                    takecallPressed(item){alert(item.taken)}
                  
                    updateData(){
                      this.items.unshift({
                        title: "Added",
                        text: "Take Now",
                        name: "Sam",
                        number: "(555) 555-5555",
                        taken: false,
                        responder: {}
                      })
                    }
                  
                    addItem(){
                      let prompt = this.alertCtrl.create({
                        title: 'Add Call',
                        message: "Enter the details for the call you want to add",
                        inputs: [
                          { name: 'title',  placeholder: 'Title'},
                          { name: 'text',  placeholder: 'Details'},
                          { name: 'name',  placeholder: 'Name'},
                          { name: 'number',  placeholder: 'Number'},
                        ],
                        buttons: [
                          { text: 'Cancel',handler: data => {}},
                          { text: 'Save',handler: data => {
                              this.items.unshift({
                                title: data.title,text: data.text,
                                name: data.name,number: data.number,
                                taken: false,responder: {}
                              })
                            }
                          }
                        ]
                      });
                      prompt.present();
                    }
                  }
                  

                  tabs.html

                  <ion-tabs>
                        <ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
                        <ion-tab [root]="tab2Root" tabTitle="Current" tabIcon="alarm"></ion-tab>
                        <ion-tab [root]="tab3Root" tabTitle="Account" tabIcon="contacts"></ion-tab>
                  </ion-tabs>
                  

                  tabs.ts

                  import { Component } from '@angular/core';
                  import { HomePage } from '../home/home';
                  import { AboutPage } from '../about/about';
                  import { ContactPage } from '../contact/contact';
                  
                  @Component({
                    templateUrl: 'tabs.html'
                  })
                  export class TabsPage {
                    // this tells the tabs component which Pages
                    // should be each tab's root Page
                    tab1Root: any = HomePage;
                    tab2Root: any = AboutPage;
                    tab3Root: any = ContactPage;
                  
                    constructor() {
                  
                    }
                  }
                  

                  推薦答案

                  有幾種方法可以實現.

                  1. Events 將是傳遞數據的正確選擇不同頁面之間.

                  1. Events would be the right choice when it comes to passing data between different pages.

                  Events 是一個發布-訂閱風格的事件系統,用于發送和在您的應用中響應應用級事件.

                  Events is a publish-subscribe style event system for sending and responding to application-level events across your app.

                  創建一個事件

                  constructor(public events: Events) {}
                  function sendData(data) {
                    events.publish('data:created', data);
                  }
                  

                  使用訂閱它

                  events.subscribe('data:created', (data) => {控制臺.log(數據);});

                  <小時>

                  1. 使用共享服務

                  1. Use a shared service

                  構造函數(公共共享:共享){}推送數據(數據){this.shared.items.push(data);}

                  app.module.ts中全局注入服務時,可以使用this.shared.items訪問其他組件中的items/p>

                  You can access items in other components using this.shared.items when you inject the service globally in app.module.ts

                  <小時>

                  1. 另一種選擇是使用 segments 而不是 tabs.這取決于用例.對于簡單的應用程序,這將是更好的解決方案.您可以從文檔了解更多信息.
                  1. Another option would be to use segments instead of tabs. This depends on the use case. For simple applications, this would be the better solution. You can learn more from the documentation.

                  編輯

                  我避免將數據存儲在數據庫中,因為它不是一種有效的方法.但這種方法可能會有用例.

                  I have avoided storing the data in database as its not an efficient way to do this. But there may be use cases for such an approach.

                  這篇關于如何在 Ionic 中的選項卡之間傳遞數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  <tfoot id='Rn3k8'></tfoot>
                  <i id='Rn3k8'><tr id='Rn3k8'><dt id='Rn3k8'><q id='Rn3k8'><span id='Rn3k8'><b id='Rn3k8'><form id='Rn3k8'><ins id='Rn3k8'></ins><ul id='Rn3k8'></ul><sub id='Rn3k8'></sub></form><legend id='Rn3k8'></legend><bdo id='Rn3k8'><pre id='Rn3k8'><center id='Rn3k8'></center></pre></bdo></b><th id='Rn3k8'></th></span></q></dt></tr></i><div class="cccmc2k" id='Rn3k8'><tfoot id='Rn3k8'></tfoot><dl id='Rn3k8'><fieldset id='Rn3k8'></fieldset></dl></div>

                  1. <legend id='Rn3k8'><style id='Rn3k8'><dir id='Rn3k8'><q id='Rn3k8'></q></dir></style></legend>
                      • <bdo id='Rn3k8'></bdo><ul id='Rn3k8'></ul>

                        <small id='Rn3k8'></small><noframes id='Rn3k8'>

                            <tbody id='Rn3k8'></tbody>
                          1. 主站蜘蛛池模板: 伺服电机维修、驱动器维修「安川|三菱|松下」伺服维修公司-深圳华创益 | 北京印刷厂_北京印刷_北京印刷公司_北京印刷厂家_北京东爵盛世印刷有限公司 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | WF2户外三防照明配电箱-BXD8050防爆防腐配电箱-浙江沃川防爆电气有限公司 | 污水提升器,污水提升泵,地下室排水,增压泵,雨水泵,智能供排水控制器-上海智流泵业有限公司 | 培训无忧网-教育培训咨询招生第三方平台 | EFM 022静电场测试仪-套帽式风量计-静电平板监测器-上海民仪电子有限公司 | LHH药品稳定性试验箱-BPS系列恒温恒湿箱-意大利超低温冰箱-上海一恒科学仪器有限公司 | 真空粉体取样阀,电动楔式闸阀,电动针型阀-耐苛尔(上海)自动化仪表有限公司 | 温泉机设备|温泉小镇规划设计|碳酸泉设备 - 大连连邦温泉科技 | 山东聚盛新型材料有限公司-纳米防腐隔热彩铝板和纳米防腐隔热板以及钛锡板、PVDF氟膜板供应商 | 菏泽商标注册_菏泽版权登记_商标申请代理_菏泽商标注册去哪里 | 航空铝型材,7系铝型材挤压,硬质阳*氧化-余润铝制品 | 吲哚菁绿衍生物-酶底物法大肠菌群检测试剂-北京和信同通科技发展有限公司 | 干培两用箱-细菌恒温培养箱-菲斯福仪器 | RTO换向阀_VOC高温阀门_加热炉切断阀_双偏心软密封蝶阀_煤气蝶阀_提升阀-湖北霍科德阀门有限公司 | 上海道勤塑化有限公司 | 工业用品一站式采购平台|南创工品汇-官网|广州南创 | 防火门|抗爆门|超大门|医疗门|隔声门-上海加汇门业生产厂家 | 国产液相色谱仪-超高效液相色谱仪厂家-上海伍丰科学仪器有限公司 | 耐压仪-高压耐压仪|徐吉电气 | 精密五金冲压件_深圳五金冲压厂_钣金加工厂_五金模具加工-诚瑞丰科技股份有限公司 | 广东恩亿梯电源有限公司【官网】_UPS不间断电源|EPS应急电源|模块化机房|电动汽车充电桩_UPS电源厂家(恩亿梯UPS电源,UPS不间断电源,不间断电源UPS) | 超声波反应釜【百科】-以马内利仪器 | 化工ERP软件_化工新材料ERP系统_化工新材料MES软件_MES系统-广东顺景软件科技有限公司 | 番茄畅听邀请码怎么输入 - Dianw8.com | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 【孔氏陶粒】建筑回填陶粒-南京/合肥/武汉/郑州/重庆/成都/杭州陶粒厂家 | 绿叶|绿叶投资|健康产业_绿叶投资集团有限公司 | 环讯传媒,永康网络公司,永康网站建设,永康小程序开发制作,永康网站制作,武义网页设计,金华地区网站SEO优化推广 - 永康市环讯电子商务有限公司 | 【甲方装饰】合肥工装公司-合肥装修设计公司,专业从事安徽办公室、店面、售楼部、餐饮店、厂房装修设计服务 | 搪瓷反应釜厂家,淄博搪瓷反应釜-淄博卓耀 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 宁夏档案密集柜,智能密集柜,电动手摇密集柜-盛隆柜业宁夏档案密集柜厂家 | 上海地磅秤|电子地上衡|防爆地磅_上海地磅秤厂家–越衡称重 | 安平县鑫川金属丝网制品有限公司,防风抑尘网,单峰防风抑尘,不锈钢防风抑尘网,铝板防风抑尘网,镀铝锌防风抑尘网 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | 江苏皓越真空设备有限公司 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | hdpe土工膜-防渗膜-复合土工膜-长丝土工布价格-厂家直销「恒阳新材料」-山东恒阳新材料有限公司 ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | 影合社-影视人的内容合作平台|