提交表单ionic 2x后切换到其他标签

时间:2018-07-06 11:08:03

标签: typescript ionic2

当用户单击时,在选项卡之间导航非常有效,根据我目前正在做的事情,我试图在用户提交表单后切换到其他选项卡

tabs.html

<ion-tabs  [selectedIndex]="{{changTab}}">
    <ion-tab tabTitle="Home" [root]="setTab1" tabIcon="home"></ion-tab>
   <ion-tab  tabTitle="Search" [root]="setTab2" tabIcon="search"></ion-tab>
   <ion-tab  tabTitle="Lessons" [root]="setTab3" tabIcon="book"></ion-tab>
   <ion-tab  tabTitle="Notifications" [root]="setTab4" tabIcon="star"></ion-tab>
   <ion-tab  tabTitle="Account" [root]="setTab5" tabIcon="person"></ion-tab>
 </ion-tabs>

signup.ts

signUp(){
this.http.post('url',{'fullname':this.fullname,'password':this.password}).map(res=>res.json()).subsribe(data=>{
console.log(data(JSON.stringfy));
this.changTab=3
})
}

1 个答案:

答案 0 :(得分:0)

尝试一下,希望对您有所帮助。

创建

import { Component, ViewChild } from '@angular/core';
 export class ClassName {
   /*ADD this inside your class */
   @ViewChild("paymentTabs") paymentTabs: Tabs;

在此处添加

 /* add paymentTabs  with # ion-tabs*/
<ion-tabs #paymentTabs [selectedIndex]="{{changTab}}">

致电此处

  /* Select tab via index*/
this.paymentTabs.select(1);

希望它能对您有所帮助。