从嵌套视图链接

时间:2015-03-10 18:26:35

标签: ionic angular-routing nested-views

我正在使用离子框架构建应用程序。我有一些嵌套状态,带有可以链接的侧边菜单。问题是,当我在#/ cards / overview时,我无法链接到#/ promos / overview。这适用于离子服务,但不能安装在设备上。

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'
        })
})

我尝试尽可能好地创建CodePen http://codepen.io/Gothematic/pen/OPBJEW

1 个答案:

答案 0 :(得分:0)

我自己找到了这个,在我的templateUrl中有一个尾随斜杠。 我的设备无法找到&#39; / templates&#39;。

的路径