[英]Calling a function directly from Ionic tab - angularjs
I am trying to create my first App with Ionic. 我正在尝试使用Ionic创建我的第一个应用程序。 I have a few tabs as defined in app.js file.
我有一些在app.js文件中定义的标签。
.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. 在这里的最后一个标签中,我不想打开新页面,如当前显示的tab-audioplayer.html。 Instead, I want to call a function say MyFunction() residing in "ChatsCtrl" controller (the previous one), which does some value assignments.
相反,我想调用一个驻留在“ ChatsCtrl”控制器(上一个)中的函数MyFunction(),该函数执行一些值分配。 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
). 不要在模板中使用ion-tab指令,而只需使用
<a>
标记并在其上ng-click
ng-它应该可以正确地放置在<ion-tabs>
容器中,并相应地设置样式(可以给.tab-item
)。 I believe the ion-tab
directive prevents any other actions from happening registered to the click event. 我相信
ion-tab
指令可防止任何其他操作发生在click事件中注册。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.