Option url path UI-Router

微笑、不失礼 提交于 2019-12-06 16:19:10
Radim Köhler

There is almost the same Q & A: Angular js - route-ui add default parmeter or another here

The solution is to create root state like this:

.state('localization', {
    url: '/{locale:(?:en|es|cs)}',
    abstract: true,
    template: '<div ui-view=""></div>',
    params: {locale : { squash : true, value: 'en' }}
})

Any child state then can just use this as a parent:

.state('home', {
    parent: 'localization', // parent will do the magic
    url: "/",
    ...
})
.state('activity', {
    parent: 'localization',
    ...

Check it here, where is also fully working plunker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!