UI 路由器重新路由 AngularJS

UI Router reroute AngularJS

我想将所有指向 /profiles/1/view 的 URL 重新路由到 /profiles/1/edit:

/profiles/1/view/account   -> /profiles/1/edit/account
/profiles/1/view/messages  -> /profiles/1/edit/messages
/profiles/1/view/settings  -> /profiles/1/edit/settings

我可以做类似下面的事情吗?源代码末尾的 * 表示匹配任何内容。对于目的地,我想在最后粘贴任何 * 对应的 * 的值。

$urlRouterProvider.when('/profiles/view/{profile_id:[0-9]{0,4}}/*', '/profiles/edit/{profile_id:[0-9]{0,4}}/*');

在 UI 路由器文档中

'/files/{path:.*}' - Matches any URL starting with '/files/' and captures the rest of the path into the parameter 'path'. '/files/*path' - Ditto. Special syntax for catch all.

考虑到这一点,您是否尝试过:

$urlRouterProvider.when('/profiles/view/{profile_id:[0-9]{0,4}}/*extra', '/profiles/edit/{profile_id:[0-9]{0,4}}/*extra');