相关疑难解决方法(0)

angularjs路由可以有可选的参数值吗?

我可以设置一个带有可选参数的路径(相同的模板和控制器,但如果它们不存在,应该忽略一些参数吗?

所以不是写下面两条规则,而是只有一条规则?

module.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
     when('/users/', {templateUrl: 'template.tpl.html', controller: myCtrl}).            
     when('/users/:userId', {templateUrl: 'template.tpl.html', controller: myCtrl})
}]);
Run Code Online (Sandbox Code Playgroud)

像这样的东西([这个参数是可选的])

when('/users[/:userId]', {templateUrl: 'template.tpl.html', controller: myCtrl})
//note: this previous doesn't work
Run Code Online (Sandbox Code Playgroud)

我在他们的文档中找不到任何内容.

angularjs angularjs-routing

165
推荐指数
3
解决办法
14万
查看次数

angular ui路由器的默认路由

angular ui路由器的示例演示具有此开始页面的链接:

'ui-router'的完整网址是/http://angular-ui.github.io/ui-router/sample/#/

'about'的完整网址是/abouthttp://angular-ui.github.io/ui-router/sample/#/about

当我使用durandalJS时,有一个限制,默认网址只是"/",可能没有"/ ui-router".

角度ui路由器插件有相同的限制吗?

angularjs angular-ui-router

19
推荐指数
4
解决办法
5万
查看次数