Ionic switch between tabs with parameters -
i have app tabs, first tab show latest post , input search user can filter results.
when user makes search, want switch second tab, manage search , display results. want keep first tab showing latest post.
the code switching second tab is:
$scope.search_posts = function() { if ( !angular.isundefined($scope.searchtext) && $scope.searchtext.length > 2 ) { $scope.searchtext = ''; $scope.show_search_box = false; $ionictabsdelegate.select($ionictabsdelegate.selectedindex() + 1); } else { $ionicloading.show({ template: 'you must write @ least 3 characters long.', nobackdrop: false, duration: 2000 }); } }
...but not know how send 'searchtext' parameter when switching.
how can accomplish this?
you use $rootscope
store shared data:
$scope.search_posts = function() { if ( !angular.isundefined($scope.searchtext) && $scope.searchtext.length > 2 ) { $rootscope.searchtextfromtabone = $scope.searchtext; $scope.searchtext = ''; $scope.show_search_box = false; $ionictabsdelegate.select($ionictabsdelegate.selectedindex() + 1); } else { $ionicloading.show({ template: 'you must write @ least 3 characters long.', nobackdrop: false, duration: 2000 }); } } //in tab two's controller $scope.searchtext = $rootscope.searchtextfromtabone;
Comments
Post a Comment