【问题标题】:Ionic view goes blank离子视图变为空白
【发布时间】:2015-08-28 12:04:58
【问题描述】:

我遇到了这个问题:我的 Ionic 应用程序有这个路由模式

$stateProvider
    .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html'
})
    .state('tab.plazas', {
    url: '/plazas',
    views: {
        'tab-plazas': {
            templateUrl: 'templates/tab-plazas.html',
            controller: 'PlazasCtrl'
        }
    }
})
    .state('tab.plaza-detalle', {
    url: '/plazas/:plazaId',
    views: {
        'tab-plazas': {
            templateUrl: 'templates/plaza-detalle.html',
            controller: 'PlazaDetalleCtrl'
        }
    }
})

    .state('tab.plaza-diagrama', {
    url: '/plazas/diagramaPlaza/:plazaId',
    views: {
        'tab-plazas': {
            templateUrl: 'templates/diagrama.html',
            controller: 'DiagramaCtrl'
        }
    }
});

我想从 plazas/:plazaId 内部转到 /plazas/diagramaPlaza/:plazaId,但是当我尝试这样做时,应用程序变为空白,当我在桌面上测试应用程序时,它运行良好,但白色当我构建应用程序并用我的手机测试它时出现屏幕。

有什么想法可能是导致此问题的原因吗?

非常感谢您的帮助。

【问题讨论】:

    标签: angularjs ionic angular-routing


    【解决方案1】:

    我建议您应该首先为您的route-configuration 配置其他方法,例如

    $urlRouterProvider.otherwise('your default view');
    

    如何转换到其他视图很重要,请尝试使用

    $state.go('tab.plaza-diagrama');
    

    这应该可以解决你的问题。

    【讨论】:

    • 哇,感谢 Damian,使用 $state.go 解决了我的问题(困扰我两天的问题)非常感谢!