this part of the ion-nav-view documentation doesn't make sense to me - ionic-framework

The example code for the ion-nav-view directive doesn't actually show its usage.
So I'm unsure how to use it.
Here is the link to the documentation:
http://ionicframework.com/docs/api/directive/ionNavView/
under the USAGE heading it says this:
on app start, $stateProvider will look at the url, see if it matches
the index state, and then try to load home.html into the
.
Pages are loaded by the URLs given. One simple way to create templates
in Angular is to put them directly into your HTML file and use the
syntax. So here is one way to put
home.html into our app:
<script id="home" type="text/ng-template">
<!-- The title of the ion-view will be shown on the navbar -->
<ion-view view-title="Home">
<ion-content ng-controller="HomeCtrl">
<!-- The content of the page -->
Go to music page!
</ion-content>
</ion-view>
</script>
This is good to do because the template will be cached for very fast
loading, instead of having to fetch them from the network.
Do I nest all of that inside of an ion-nav-view directive? Another reason for my confusion is because in one of the ionic templates the framework provides I've seen ion-nav-view opened and closed with nothing in between it this (code below is copy and pasted directly from one of Ionic's templates) :
<body ng-app="myApp">
<!--
The nav bar that will be updated as we navigate between views.
-->
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
</body>

This <ion-nav-view> behaves like a placeholder. Your other html files that you create under templates folder goes in there. So for example you then have "employees.html" in your templates folder. So the markup of "employees.html" will look something like this:
<ion-view view-title="Employees">
<ion-content>
<ion-list>
<ion-item ng-repeat="item in items">
Hello, {{item}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
the above is complete html that will be sitting in "employees.html". Basically this is the html that will be placed inside <ion-nav-view> tags.
Hope this helps.

Related

ion-content won't show when using Ionic core 4

I'm developing an app that uses Vue.js and Ionic, but I can't figure it out why updating my Ionic core version breaks the ion-content tag, I tried googling if the tag was discontinued, but it doesn't seem to be the case.
To illustrate, I've made a example that uses Ionic core. With the latest Ionic version the ion-content tag doesn't show up, but if you switch to the older Ionic version, then it shows just fine.
<head>
<meta charset="UTF-8">
<title>Ionic Test</title>
<script src="https://unpkg.com/#ionic/core#latest/dist/ionic.js"></script>
<!-- <script src="https://unpkg.com/#ionic/core#0.0.2-30/dist/ionic.js"></script> -->
</head>
<body>
<ion-app>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>Example</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="content" padding>
<ion-list>
</ion-item>
<ion-label full>I'm an example text...</ion-label>
<ion-button>Example button</ion-button>
</ion-item>
</ion-list>
</ion-content>
</ion-page>
</ion-app>
</body>
Here's a jsFiddle for this code: https://jsfiddle.net/telmo/chk9h080/
Can someone explain to me what is happening here?
Since #ionic/core (aka Ionic4) version 0.0.4, there is no more <ion-page>. You directly put your header and content under the <ion-app>.
If really necessary, you can wrap them in a <div class="ion-page">.
Actually There is some height problem,so import css and write this code
......
css
.height{
height:100vh
}
It will solve your error

hide menu button on specific view without hiding navbar (ionic)

There are similar question but not this exact one. I have this structure in an ionic app view
<ion-view>
<ion-nav-title>
<a id="go_to_app" href="#startseite">
<span class="ion-android-exit"></span>
</a>
<img src="img/logo_header.png">
</ion-nav-title>
<ion-content class="star-wrap">
.
. contents
.
</ion-content class="star-wrap">
What I'm trying to achieve is show the ion-android-exit button instead of the menu button in this specific view.
Is this possible?
There was a (way) easy and simple way to do this.
Adding <ion-nav-buttons></ion-nav-buttons> inside <ion-view></ion-view> will rewrite the menu button with whatever I want, or just hide it with no contents.
You need to use ng-if like in example here.
http://codepen.io/anon/pen/AXkJGa
after setting the value of ng conditional to true in the controller.
Example HTML
<title>Ionic Modal</title>
<body ng-controller="State1Ctrl">
<ion-nav-bar>
<ion-nav-view>
<ion-view>
<ion-nav-title>
<a id="go_to_app" href="#startseite">
<span class="ion-android-exit" ng-if="!hidethisview"></span>
</a>
</ion-nav-title>
<ion-content>
Some super content here!
</ion-content>
</ion-view>
</ion-nav-view>
</ion-nav-bar>
And JS
angular.module('ionicApp', ['ionic'])
.controller('State1Ctrl', function($scope, $state) {
if($state.current.name=="")// you need to have your state name inside quotes
//this example don't have one
{
$scope.hidethisview=true;
}
});

Ionic tabs hidden beneath the header

I have a blank app with many pages. One of these pages needs to be diveded into tabs.
I want a few tabs to be displayed under the header (which has logo and back button).
However, for some reason, the tabs are hidden almost completly beneath the header.
The structure is the following:
<ion-view view-title="MyPage">
<ion-header-bar align-title="center">
<div class="app_header_side">
<button class="button back-button">
<i class="icon ion-ios-arrow-back"></i>
</button>
</div>
<div class="app_header_center">
<div class="text-center">
LOGO
</div>
</div>
<div class="app_header_side">
</div>
</ion-header-bar>
<ion-content class="padding has-header">
<ion-tabs class="tabs-positive tabs-icon-top">
<ion-tab title="All time" icon-on="ion-ios-filing" icon-off="ion-ios-filing-outline">
<!-- Tab 1 content -->
</ion-tab>
<ion-tab title="Month" icon-on="ion-ios-clock" icon-off="ion-ios-clock-outline">
<!-- Tab 2 content -->
</ion-tab>
<ion-tab title="Week" icon-on="ion-ios-gear" icon-off="ion-ios-gear-outline">
<!-- Tab 3 content -->
</ion-tab>
</ion-tabs>
</ion-content>
</ion-view>
I have tried to put the tabs everywhere. In the header, before "ion-view", before "ion-content". Nothing worked.
The only way to make ti work was to add
style="padding-top: 30px;"
in the tag for "ion-content". But I would prefer to avoid putting fixed padding.
I would suggest the following by declaring the header as follow:
<ion-header-bar class="bar-header">
and then defining the has-header
<ion-content class="has-header">
Alternatively as a test you can set:
<ion-content class="has-subheader">
That would imply that something like a ion-nav-bar for example is set as the header already. Then set the ion-header-bar as bar-subheader.
IONIC Headers and Sub-Headers
Alternatively you can place tab at bottom same like iOS.
Set $ionicConfigProvider.tabs.position('bottom'); in .config
I think you should try
<ion-view view-title="MyPage" class="has-header">
I came across same issue once. I used class="has-header" to root view that solved my problem.

ionic: Fixed title in ion-nav-bar

I'm trying to get a fixed title in the ion-nav-bar (text or image). For a app i'm building I just need a back icon and a logo/brandname in the navbar that doesn't fade from view to view.
Can anyone help me/give me a hint to achieve this.
Thanks in advance.
Please use this body in your index.html.
Put the content of your header bar in . Don't declare ion-nav-bar in any of your templates, so that they will inherit the header from index.html.
<body ng-app="app">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-icon">
<i class="ion-arrow-left-c"></i> Back
</ion-nav-back-button>
Your logo/name
</ion-nav-bar>
<ion-nav-view>
</ion-nav-view>
</body>

Ionic: ion-nav-bar declared "globally" does not work?

I've got this strange behaviour.
In my index.html I declared:
<body>
<ion-nav-view></ion-nav-view>
</body>
Then in my page.html I used the followin markup:
<ion-view title="Purchases" hide-back-button="true">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content> ... </ion-content>
</ion-view>
The view correctly set a button to toggle side menu, but also, automatically, create a header:
<ion-nav-bar class="bar-stable nav-title-slide-ios7 bar bar-header nav-bar disable-user-behavior">
How can I change its styles? For instance: I would like to set it as a "bar-energized".
I also tried to insert, in index.html above , the following markup (amany examples show), but it does not seem to work (nav bar header remains grey):
<ion-nav-bar class="bar-energized nav-title-slide-ios7"></ion-nav-bar>
The only way it seems working is by declaring and buttons inside each and every
Just realized it was really a newbie question! I was starting from a Ionic sidemenu template, and the misterious "bar-stable" was declared inside "ion-pane ion-side-menu-content" in my menu.html file.
Hope it may helps someone other!