Trying to create a URL matching for a configuration page on my Angular site. I'm using Angular Router UI and according to the documentation it should be possible to match non-capturing groups.
尝试为我的Angular站点上的配置页面创建URL匹配。我正在使用Angular Router UI,根据文档,它应该可以匹配非捕获组。
What I am trying to do is match both /config and /configuration. However I cannot get this to work, and when I click a link to ui-sref="configuration" I end up with an address which looks like this: localhost:8080/#/config( <--- Note the ending parenthesis
我想要做的是匹配/ config和/ configuration。但是我无法使用它,当我点击指向ui-sref =“configuration”的链接时,我最终得到一个如下所示的地址:localhost:8080 /#/ config(<---注意结束括号
Can anyone help me with this?
Code provided below.
谁能帮我这个?代码如下。
// Define configuration module
angular.module('configuration')
.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('configuration', {
url: '/config(?:uration)?',
controller: 'ConfigurationController',
templateUrl: 'visualization/configuration/configuration.html'
});
}]);
1 个解决方案
#1
1
You cannot give multiple urls to a single state in the above way. But, instead, you could use the $urlRouterProvider service to redirect a url to another. For help please read this
您不能以上述方式为单个州提供多个网址。但是,您可以使用$ urlRouterProvider服务将URL重定向到另一个URL。如需帮助,请阅读此内容
#1
1
You cannot give multiple urls to a single state in the above way. But, instead, you could use the $urlRouterProvider service to redirect a url to another. For help please read this
您不能以上述方式为单个州提供多个网址。但是,您可以使用$ urlRouterProvider服务将URL重定向到另一个URL。如需帮助,请阅读此内容