ionic-frameworkangular-routingnested-views

Linking from nested views


I'm building an app using the ionic framework. I have some nested states with a side-menu from where I can link. The thing is that when I'm at #/cards/overview, I'm unable to link to #/promos/overview. This works with ionic serve, but not when installed on a device.

angular.module('CLP', ['ionic', 'ngCordova', 'utils'])

.config(function ($stateProvider, $urlRouterProvider) {
            $urlRouterProvider.otherwise('/cards/overview');
    $stateProvider
        .state('promos', {
            abstract : true,
            templateUrl: 'templates/promos/promos.html'
        })
        .state('promos.main', {
            abstract : true,
            url: '/promos',
            views: {
                sidebarLeft: {
                    templateUrl: 'templates/sidebar/left.html'
                },
                mainContent: {
                    template: '<ion-nav-view></ion-nav-view>'
                }
            }
        })
        .state('promos.main.overview', {
            cache : false,
            url: '/overview',
            templateUrl: 'templates/promos/overview.html'
        })
            .state('cards', {
            abstract : true,
            templateUrl: 'templates/cards/cards.html',
        })
        .state('cards.main', {
            abstract : true,
            url: '/cards',
            views : {
                sidebarLeft: {
                    templateUrl: 'templates/sidebar/left.html',
                    controller: 'sidebarCtrl'
                },
                mainContent: {
                    template: '<ion-nav-view></ion-nav-view>'
                }
            }
        })
        .state('cards.main.overview', {
            cache : false,
            url: '/overview',
            templateUrl: 'templates/cards/overview.html',
            controller: 'cardsOverview'
        })
        .state('cards.main.detail', {
            cache : false,
            url: '/:cardId',
            templateUrl: 'templates/cards/detail.html',
            controller: 'showDetail'
        })
})

I tried to create a CodePen, as good as possible http://codepen.io/Gothematic/pen/OPBJEW


Solution

  • Found this myself, somewhere in my templateUrl there was a trailing slash. My device couldn't found the path to '/templates'.