Angularjs 1.x——UIRouter路径/XYZ vs//XYZ
我试图在顶层创建一个path变量。例如:website.com/XYZ123,其中XYZ123是一些帐户代码。如何在angular应用程序中实现这一点 我的配置如下:Angularjs 1.x——UIRouter路径/XYZ vs//XYZ,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我试图在顶层创建一个path变量。例如:website.com/XYZ123,其中XYZ123是一些帐户代码。如何在angular应用程序中实现这一点 我的配置如下: $urlRouterProvider.otherwise('/'); .state ('/', { url: '/', templateUrl: 'views/landing.html', controller: 'landingCtrl',
$urlRouterProvider.otherwise('/');
.state ('/', {
url: '/',
templateUrl: 'views/landing.html',
controller: 'landingCtrl',
authenticate: false
}).state ('signin', {
url: '/{accountCode:[0-9A-Z]{6}}',
templateUrl: 'views/student/signin.html',
controller: 'studentSigninCtrl',
authenticate: false
})
www.website.com//XYZ123-工程。。但我该怎么做才能让website.com/XYZ123也去angularjs水疗中心呢
感谢主模块中的配置块,您可以使用$locationProvider关闭HTML5模式,而不在路由中显示哈希:
// Removes the fragment identifier ('#') from urls
$locationProvider.html5Mode(true);
注意:这样做有一些注意事项,主要是您需要确保在主索引HTML文件中包含一个标记:
<head>
<base href="/"/>
</head>
有关记录在案的参考资料,请参阅。非常感谢您为我指明了正确的方向,并及时回复@JBNizetI。。只要我在应用程序中,它就工作得很好。但当我点击浏览器刷新按钮时,我无法获取/3R2YA2我将在aws上的s3/cloudfront上托管此应用程序,因此我不确定是否需要更改某些内容,以便书签等可以在我的应用程序上运行。有什么建议吗?@AliceWaterland,我认为您需要了解刷新AngularJS SPA应用程序时会发生什么。