I can not get `ion-nav-view` to work

I tried to implement ion-nav-viewfrom Ionic so that I could get a toolbar similar to the Android Native toolbar. To do this, I followed the instructions described here .

So, I created the following index.html:

<!DOCTYPE html>
<html data-ng-app="myApp">

<head>
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">

    <!-- Ionic -->
    <link rel="stylesheet" type="text/css" href="lib/ionic/css/ionic.css">
    <script type="text/javascript" src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- myApp -->
    <link rel="stylesheet" type="text/css" href="css/general.css">
    <script type="text/javascript" src="js/app.js"></script>
    <script type="text/javascript" src="js/factory.js"></script>
    <script type="text/javascript" src="js/controller.js"></script>
</head>

<body>
    <ion-nav-bar class="bar-positive">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view></ion-nav-view>
</body>

</html>

And this is app.js:

var myApp = angular.module('myApp', ['ionic']);

myApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider.state('index', {
        url: '/',
        templateUrl: 'views/home.html'
    }).state('prints', {
        url: '/prints',
        templateUrl: 'views/photo_prints.html'
    }).state('box', {
        url: '/box',
        templateUrl: 'views/photo_box.html'
    }).state('framed', {
        url: '/framed',
        templateUrl: 'views/photo_framed.html'
    }).state('xxl', {
        url: '/xxl',
        templateUrl: 'views/photo_xxl.html'
    }).state('collage', {
        url: '/collage',
        templateUrl: 'views/photo_collage.html'
    }).state('coupon', {
        url: '/coupon',
        templateUrl: 'views/photo_coupon.html'
    });

    $urlRouterProvider.otherwise("/");
});

To show an example here views / home.html:

<script id="home" type="text/ng-template">
    <ion-view view-title="Home">
        <ion-content ng-controller="HomeController">
            <a href="#/prints">Prints</a>
            <a href="#/box">Box</a>
            <a href="#/book">Book</a>
        </ion-content>
    </ion-view>
</script>

But when I started the application now, I see the following:

enter image description here

The documentation states the following:

Then when the application starts, $ stateProvider will look at the URL, see that it matches the state of the index, and then try to load home.html into <ion-nav-view>.

So either the application is not in the index state when I run it, or I have another error. Can someone help me?

+4
1

home.html html, <script id="home" type="text/ng-template">, - ng-template URL- home $templateCache angular

script . , html

home.html

<ion-view view-title="Home">
    <ion-content ng-controller="HomeController">
        <a href="#/prints">Prints</a>
        <a href="#/box">Box</a>
        <a href="#/book">Book</a>
    </ion-content>
</ion-view>
+4

All Articles