ionic開發中頁面跳轉隱藏ion-tabs__ionic

來源:互聯網
上載者:User

情境描述:


點擊測試裝置1跳轉到裝置詳情頁,在裝置詳情頁隱藏底部的標題列ion-tabs,當頁面從裝置詳情頁返回到首頁時,顯示底部標題列。

具體步驟:

1.在ion-tabs後添加

ng-class="{'tabs-item-hide': $root.hideTabs}"

2.在app.js中添加

.directive('showTabs', function ($rootScope) {  return {    restrict: 'A',    link: function ($scope, $el) {      $rootScope.hideTabs = false;    }  };}).directive('hideTabs', function ($rootScope) {  return {    restrict: 'A',    link: function ($scope, $el) {      $rootScope.hideTabs = true;    }  };})
3.隱藏,在裝置詳情頁中的ion-view後添加
hide-tabs

4.顯示,在首頁的控制器中添加

$scope.$on('$ionicView.enter', function () {    // 顯示 tabs    $rootScope.hideTabs = false;})

注意:此處要在function後添加$rootScope,代碼如下

.controller('homeController',function($scope,$rootScope){    $scope.title='首頁'    $scope.items = [];    for(var i=0;i<10;i++)        $scope.items.push(["測試裝置 ",i+1].join(""))    $scope.$on('$ionicView.enter', function () {        // 顯示 tabs        $rootScope.hideTabs = false;    })})
這樣就實現了上述情境描述中的功能。

由於剛開始接觸ionic開發,很多東西還不是很懂,說的有些墨跡,見諒...

參考網址:http://www.cnblogs.com/maoyazhi/p/4424039.html





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.