AngularJs用户界面路由器自定义url

AngularJs用户界面路由器自定义url,angularjs,angular-ui-router,Angularjs,Angular Ui Router,好的,问题出在这里。我有一个应用程序,用户可以注册为商户,并可以拥有自己的店铺名称,我要查找的url是: http://localhost:8000/#/storename 这与默认主页子页面(如contactus、aboutus)发生冲突。下面是我的ui路由器的实现 这是http://localhost:8000//contact 正在访问存储模板,就好像contact是存储名称一样。默认的which inherit home.[anything]应位于父级定义的模板下。我如何解决这个问题

好的,问题出在这里。我有一个应用程序,用户可以注册为商户,并可以拥有自己的店铺名称,我要查找的url是:

http://localhost:8000/#/storename 
这与默认主页子页面(如contactus、aboutus)发生冲突。下面是我的ui路由器的实现

这是http://localhost:8000//contact 正在访问存储模板,就好像contact是存储名称一样。默认的which inherit home.[anything]应位于父级定义的模板下。我如何解决这个问题


有一种肮脏的方法可以做到这一点,即为每个子页面定义新的父页面,但这将重复页眉和页脚部分布局

据我所知,angular在处理路线时遵循自上而下的方法。所以定义

       .state('store',{
        url: '/:storename',  -->  http://localhost:8000/#/myshop [work]
            templateUrl: 'views/main_store.html'        
        })

在所有其他路线之后。在您的情况下,当angular到达/:storename时,它会认为contact是一个store name并加载该页面。要避免它,您需要将它保持在最后

define.state'store',{url:'/:storename',->[work]templateUrl:'views/main_store.html'}最后。在将home.contact状态更改为之后的所有其他常规之后contact@raj页面已加载,但未加载到内部视图/main_home.html,它直接加载到index.htmlOK。。然后,我想你也可以尝试在/contact中加载主页,并根据URL填充,我做了一些更改,但当我转到/contact页面时仍然无法工作
       .state('store',{
        url: '/:storename',  -->  http://localhost:8000/#/myshop [work]
            templateUrl: 'views/main_store.html'        
        })