I am trying to create my first App with Ionic. I have a few tabs as defined in app.js file.
.state('tab.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
.state('tab.chats', {
url: '/chats',
views: {
'tab-chats': {
templateUrl: 'templates/tab-chats.html',
controller: 'ChatsCtrl'
}
}
})
.state('tab.audioplayer', {
url: '/audioplayer',
views: {
'tab-audioplayer': {
templateUrl: 'templates/tab-audioplayer.html',
controller: 'ExampleController'
}
}
})
Here in the last tab, I do not want to open a new page like tab-audioplayer.html as currently shown. Instead, I want to call a function say MyFunction() residing in "ChatsCtrl" controller (the previous one), which does some value assignments. As I am new, I don't know how to call a function instead of opening a tab, when the tab icon is clicked.
Don't use the ion-tab directive in your template, but just use an <a>
tag and put an ng-click
on there - it should fit alright within your <ion-tabs>
container, and just style accordingly (can give it .tab-item
). I believe the ion-tab
directive prevents any other actions from happening registered to the click event.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.