Angular ui.router, Creating an Optional First Path Param

后端 未结 1 1918
忘掉有多难
忘掉有多难 2021-01-15 04:24

Relatively new to working with Angular, but I couldn\'t seem to find any url aliasing or fully optional path params (something like {/var1}/:var2 when using ui.

相关标签:
1条回答
  • 2021-01-15 04:56

    Maybe this would work

    .state('app.view', {
        url: '/:var1/:var2',
        templateUrl: 'yourTpl.html',
        controller: 'YourCtrl',
        params: {
            var1: {squash: true, value: null}
        }
    })
    

    squash configures how a default parameter value is represented in the URL when the current parameter value is the same as the default value

    0 讨论(0)
提交回复
热议问题