AngularJS 强制应用程序从特定 URL 启动 [英] AngularJS force app to start from specific URL
本文介绍了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');
问题是 otherwise
只是使用未知的 URL 并将它们重定向到 welcome
,而我想重定向到 welcome
在所有情况下,即使在已注册的州.
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屋!
查看全文