AngularJS力应用从特定的URL启动 [英] AngularJS force app to start from specific URL

查看:169
本文介绍了AngularJS力应用从特定的URL启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序特定的逻辑顺序,我想要一个简单的办法,迫使我的应用从欢迎页面开始。
我使用这样的:

I have a specific logic sequence in my app, and I want a simple way to force my app to start from the welcome page. I am using this:

$urlRouterProvider.otherwise('/pages/welcome');

问题是,,否则刚刚与未知的URL玩,将其重定向到欢迎,而我想重定向到欢迎在所有情况下,甚至在登记状态。

the problem is that otherwise just play with the unknown URLs and redirect them to the welcome, whereas I want to redirect to the welcome in all cases, even in the registered states.

推荐答案

只是一味的location.hash ='#/'; 这样的:

angular.module('app', []).config(function ($stateProvider, $urlRouterProvider) {

    location.hash = '#/';

    $stateProvider
        .state('welcome', {
            url        : '/pages/welcome',
            templateUrl: 'views/welcome.html',
            controller : 'WelcomeCtrl'
        });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/pages/welcome');        
})

这篇关于AngularJS力应用从特定的URL启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆