asad
July 21, 2014, 9:55am
1
I want to call a function on every tab will i click but it doesn’t work. How Can I call a function on tab click.
Here is the scenario
<ion-tab title="Home" icon-on="ion-ios7-filing" ng-click="calme()">
<h2>Home Content</h2>
<button class="button" ng-click="showHotel = true">Show Hotel</button>
</ion-content>
</ion-tab>
<ion-tab title="Work" icon-on="ion-ios7-filing" ng-click="calme()">
<ion-header-bar type="bar-positive" title="'Work'"></ion-header-bar>
<ion-content>
<h2>Work Content</h2>
</ion-content>
</ion-tab>
.controller(‘HomeCtrl’, function($scope) {
$scope.calme=function(){alert(“you call me”)};
});
1 Like
Auro
July 21, 2014, 10:11am
2
Add A controller to you Tabs (i do it with $stateProvider)
add ng-click to you tab
create the method
be happy it works
here a codepen: http://codepen.io/domiSchenk/pen/zHeau
only downside you need to do page changing inside the method.
2 Likes
asad
July 21, 2014, 10:55am
3
Thank you @Auro
Another Issue please see this one.
I have created the nested list have a look at that http://codepen.io/asadfida/pen/oknzL
The issue is when I select a list all the lists shows the sub-list/lists.So I want to open sub-list of only the selected item.How to I do this please guide me.
Auro
July 21, 2014, 11:21am
4
The problem your facing is, your are using a scope wide variable and you bind to only this instance for each item
what you have to do is create a individual variable for each of this list items
see here: http://codepen.io/domiSchenk/pen/sDaLG
tipp: in angular dont use ! for showing stuff, you can use ng-hide=""
1 Like
Auro
July 21, 2014, 11:37am
6
i forgot to say, that there have to be a better way to do that, but i dont know how
1 Like
asad
July 26, 2014, 11:31am
7
@Auro The Sublists show/hide very quickly. http://codepen.io/asadfida/pen/oknzL
how to make it little bit slow.(any way like css transitions on show and hide)
Auro
July 28, 2014, 9:06am
8
sorry for late response
i have worked out something:
note: you have to set
.slidedown {
max-height: 900px ;
}
to a value your list will never get.
but on closing it will have a little delay.
and i did change your links to a ul list its better to handle this.
1 Like
Justin
July 28, 2014, 12:00pm
9
ion-tab also has a on-select method that you could hook in to:
http://ionicframework.com/docs/api/directive/ionTab/
2 Likes
Please use on-select="" instead of ng-click=" ".
2 Likes
Hi Thanks for your help its working
But In my app i need to add sidemenu to same tabs page
how to do it ?
please help me…
DCole
February 5, 2017, 12:36pm
13
Saleemnasa, this may help in what you’re trying to do. It helped me.
Sorry for the late response.