Sat*_*000 14 ionic-framework ionic
我正在使用离子框架,我已经创建了一个新的选项卡应用程序.
我需要做的是将一个页面作为默认页面或主页面没有选项卡,然后所有其余部分使标签正常.
像登陆页面.
我怎样才能做到这一点?
首先$stateProvider为登陆或默认页面定义一个单独的[我认为你已经$stateProvider为其他页面定义了一个] app.js.app.js文件应该是这样的,
app.js
var app = angular.module('myApp', ['ionic']);
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tabs', {
url: '/tab',
controller: 'TabsCtrl',
templateUrl: 'tabs.html'
})
.state('tabs.home', {
url: '/home',
views: {
'home-tab': {
controller: 'homeCtrl',
templateUrl: 'home.html'
}
}
})
.state('tabs.settings', {
url: '/settings',
views: {
'settings-tab': {
controller: ' signOutCtrl',
templateUrl: 'settings.html'
}
}
});
$stateProvider
.state('landing', {
url: '/landing',
controller: 'landingCtrl',
templateUrl: 'landing.html'
});
$urlRouterProvider.otherwise('/landing');
});
Run Code Online (Sandbox Code Playgroud)
还为选项卡创建一个html页面.
tabs.html
<ion-view title="Home">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button>
</ion-nav-buttons>
<ion-tabs class="tabs-icon-top tabs-positive">
<ion-tab title="{{tab1Title}}" icon="ion-home" href="#/tab/home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="{{tab2Title}}" icon="ion-gear-a" href="#/tab/settings">
<ion-nav-view name="settings-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="{{tab3Title}}" href="#/landing" icon="ion-log-out">
</ion-tab>
</ion-tabs>
</ion-view>
Run Code Online (Sandbox Code Playgroud)
您还需要使用隐藏 <ion-nav-bar>在landing页面中hide-nav-bar="true ".
landing.html上
<ion-view hide-nav-bar="true ">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button>
</ion-nav-buttons>
<ion-content padding="true">
<h1 style="text-align: center;">Welcome To Landing Page</h1>
<a class="button icon-right ion-chevron-right button-calm" ng-click="open()">Lets Go</a>
</ion-content>
</ion-view>
Run Code Online (Sandbox Code Playgroud)
在最近的离子版本中,这可以通过设置轻松实现
$ionicTabsDelegate.showBar(false);
Run Code Online (Sandbox Code Playgroud)
示例代码:
.directive('hideTabs', function($rootScope, $ionicTabsDelegate) {
return {
restrict: 'A',
link: function($scope, $el) {
$scope.$on("$ionicView.beforeEnter", function () {
$ionicTabsDelegate.showBar(false);
});
$scope.$on("$ionicView.beforeLeave", function () {
$ionicTabsDelegate.showBar(true);
});
}
};
})
Run Code Online (Sandbox Code Playgroud)
尝试这个很简单
<!-- in your tabs.html add this ng-class -->
<ion-tabs ng-class="{'tabs-item-hide': hideTabs}">
</ion-tabs>
<!-- add 'hide-tabs'in your view where you want to hide the tabs -->
<ion-view hide-tabs>
</ion-view>
// in your app.js add a directive
.directive('hideTabs', function($rootScope) {
return {
restrict: 'A',
link: function($scope, $el) {
$rootScope.hideTabs = true;
$scope.$on('$destroy', function() {
$rootScope.hideTabs = false;
});
}
};
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7995 次 |
| 最近记录: |