Reputation: 11420
I am new to ionic(although I have some knowledge of angularJs). I am facing problem in ion-tabs. Following is my code :-
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/home');
$stateProvider
// HOME STATES AND NESTED VIEWS ========================================
.state('home', {
url: '/home',
views: {
'': {
templateUrl: 'partial-home.html'
},
'other@home': {
template: "Hello World! I am other-11."
},
'other': {
template: "Hello World! I am other 12."
}
}
})
// nested list with custom controller
.state('home.list', {
url: '/list',
templateUrl: 'partial-home-list.html',
controller: function($scope) {
$scope.dogs = ['Bernese', 'Husky', 'Goldendoodle'];
}
})
// nested list with just some random string data
.state('home.paragraph', {
url: '/paragraph',
template: '<ion-view view-title="paragraph">I could sure use a drink right now.</ion-view>'
})
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link rel="manifest" href="manifest.json">
<!-- un-comment this code to enable service worker
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(() => console.log('service worker installed'))
.catch(err => console.log('Error', err));
}
</script>-->
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
<script type="text/ng-template" id="partial-home.html">
<ion-view view-title="def" hide-nav-bar="false" class="padding padding-vertical">
<ion-nav-buttons side="right">
<button class="button button-icon ion-home"></button>
<button class="button button-icon ion-ios-email"></button>
<button class="button button-icon ion-ios-person"></button>
</ion-nav-buttons>
<ion-tabs class="tabs-icon-top">
<ion-tab title="list" icon="icon ion-home" href="#/home/list">
<ion-nav-view name="list"></ion-nav-view>
</ion-tab>
<ion-tab title="paragraph" icon="icon ion-heart" href="#/home/paragraph">
<ion-nav-view name="paragraph"></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-view>
</script>
<script type="text/ng-template" id="partial-home-list.html">
<ion-view view-title="list">
<ul>
<li ng-repeat="dog in dogs">{{ dog }}</li>
</ul>
</ion-view>
</script>
<ion-nav-bar class="bar-positive">
<ion-nav-buttons side="left">
<button class="button button-icon ion-navicon" menu-toggle="left"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-icon ion-search"></button>
<button class="button button-icon ion-ios-email"></button>
<button class="button button-icon ion-ios-person"></button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view>
</ion-nav-view>
</body>
</html>
Following are the problems, that I am facing :- 1) Although, tabs are appearing, but when I click on individual tab, it's internal content is not getting populated with current code(that I have posted) and navbar title is also not changing, in spite of view-title property being set in each child state template.
2) In partial-home.html
template in html code, I want navbar to have some extra buttons in it, but those buttons are also not getting shown.
3) However, when I change partial-home.html
, to something given below(I have removed name property from ion-nav-view),
<script type="text/ng-template" id="partial-home.html">
<ion-view view-title="def" hide-nav-bar="false" class="padding padding-vertical">
<ion-nav-buttons side="right">
<button class="button button-icon ion-home"></button>
<button class="button button-icon ion-ios-email"></button>
<button class="button button-icon ion-ios-person"></button>
</ion-nav-buttons>
<ion-tabs class="tabs-icon-top">
<ion-tab title="list" icon="icon ion-home" href="#/home/list">
<ion-nav-view></ion-nav-view>
</ion-tab>
<ion-tab title="paragraph" icon="icon ion-heart" href="#/home/paragraph">
<ion-nav-view></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-view>
</script>
then, tab contents are appearing properly, when I click on individual tab, but tab content appears behind navbar, as shown in image given below :-
I don't know, where I am going wrong. Thanks in advance.
Upvotes: 0
Views: 1096
Reputation: 2940
script
tags to create different tab pages . I suggest you to download starter tabs template and look into thatIonic start appname tabs
navbar
buttons
include this code in the page where you want the buttons.`
<ion-nav-buttons side="right">
<button class="button" ng-click="doSomething()">doSomething</button>
</ion-nav-buttons>
The side to place the buttons in the ionNavBar. Available sides: primary, secondary, left, and right.
<ion-content>
<ion-content has-header="true">
Upvotes: 1