1.创建项目
2.路由
angular.module("starter",['ionic']) // 依赖 ionic 提供的ui-router .config(function ($stateProvider,$urlRouterProvider) { $stateProvider.state('home',{ // 状态值,可任意 url:'/', // 路由地址 templateUrl:'templates/home.html' // 对应模板 以index.html所在文件夹 www 为根路径 }) .state('music',{ url:'/music', templateUrl:'templates/music.html' }); $urlRouterProvider.otherwise('/'); // 默认跳转位置 })
3. ionic隐藏tab导航条 指令
angular.module("myapp",['ionic']) .directive('hideTabs',function($rootScope){ return { restrict:'AE', link:function($scope){ $rootScope.hideTabs = 'tabs-item-hide'; $scope.$on('$destroy',function(){ $rootScope.hideTabs = ''; }) } } }) 使用: <ion-tabs class="tabs-icon-top tabs-stable tabs-color-positive {{hideTabs}}"> ...... </ion-tabs> 需要隐藏tab页面的控制 controller($rootScope)其中添加以下内容 $rootScope.hideTabs='tabs-item-hide'; //页面销毁 $scope.$on('$destroy',function(){ console.log('$destroy'); $rootScope.hideTabs = ''; })