我如何复制标签的内容



如何复制标签的内容?

嗨,我是Ionic的新手。我有两个名为"仪表板"one_answers"朋友"的选项卡。我基本上希望两个选项卡的内容都相同并共享相同的视图和控制器。如果我单击" dahsaboard"的内容,它必须与"朋友"的内容相同,反之亦然。我要做的是,当用户单击任何选项卡上时,您可以获取选项卡的名称,例如,如果我单击"仪表板",则必须返回" dashboard"一词,与tab"相同朋友",我该怎么办?

非常感谢

.state('tab.dash', {
  url: '/dash',
  views: {
    'tab-dash': {
      templateUrl: 'tab-dash.html',
      controller: 'DashCtrl'
    }
  }
})
.state('tab.friends', {
  url: '/friends',
  views: {
    'tab-friends': {
      templateUrl: 'tab-dash.html',
      controller: 'DashCtrl'
    }
  }
})

<ion-tab title="Dashboard" icon="icon ion-home" href="#/tab/dash">
  <ion-nav-view name="tab-dash"></ion-nav-view>
</ion-tab>

<ion-tab title="Friends" icon="icon ion-heart" href="#/tab/friends">
  <ion-nav-view name="tab-friends"></ion-nav-view>
</ion-tab>

您可以使用 on-select for ion-tabs更改事件

<ion-tab on-select="doSomeForcontent('Friends')"  title="Friends" icon="icon ion-heart" href="#/tab/friends">
  <ion-nav-view name="tab-friends"></ion-nav-view>
</ion-tab>

和控制器,

$scope.doSomeForcontent = function(value){
  check here for tab name and do the logic
}

最新更新