[英]AngularJS: Dynamic URL Prefix
I have a large angular app that lives at a URL like so: 我有一个大型的角度应用程序,它的网址如下:
http://myangularapp.com/app/index.html#/
The URL I intend on giving out will need a name injected into the URL as this one site will support multiple users. 我打算提供的URL将需要在URL中注入一个名称,因为该站点将支持多个用户。
So, without modifying any directory structure, I'd like to do: 因此,在不修改任何目录结构的情况下,我想这样做:
http://myangularapp.com/app/bob/index.html#/
and also: 并且:
http://myangularapp.com/app/harry/index.html#/
All my controllers and functionality would ideally stay the same. 我所有的控制器和功能在理想情况下都保持不变。
Super stumped on this one! 超级迷上了这个!
Use the $routeProvider
service. 使用
$routeProvider
服务。 You can define where urls go, like so. 您可以像这样定义网址的位置。
$routeProvider.
when('/app/foo/bar/what/about/bob', {
templateUrl: 'app/bob/index.html', <---directory and url don't have to match
controller: 'bobController'
}).
when('/app/harry', { ...
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.