2016-06-29 5 views
0

私はタブ付きのアプリを持っています。最初のタブには最新の投稿が表示され、入力検索ではユーザーが結果をフィルタリングできます。パラメータ付きのタブ間のイオニックスイッチ

ユーザーが検索すると、検索を管理し結果を表示する2番目のタブに切り替える必要があります。私は最初のタブを最新の投稿を表示したままにしておきたい。

$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 at least 3 characters long.', noBackdrop: false, duration: 2000 }); 
     } 
    } 

...しかし、私は、切り替え時にパラメータとして「検索テキスト」を送信する方法がわからない:

2番目のタブに切り替えるためのコードです。

どのようにすればいいですか?

答えて

0

あなたは共有データを保存するために$rootScopeを使用することができます。

$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 at least 3 characters long.', noBackdrop: false, duration: 2000 }); 
    } 
} 

//in tab two's controller 
$scope.searchText = $rootScope.searchTextFromTabOne; 
+0

こんにちは、はい、私は、代わりにあなたのものよりも、同様の方法でデータを保持するために工場を使用し、正常に動作します。ありがとう。 – domoindal

関連する問題