How to disable static url in angular ui-router?

拥有回忆 提交于 2019-12-11 02:25:30

问题


I have some two ui-router states in my angular application, which works fine, like this:

app.config(["$stateProvider",
    function($stateProvider){
        $stateProvider
            .state("settings", {
                url: "/settings",
                views: {
                    "secondMenu": {
                        templateUrl: "second_menu.html?parent=settings",
                        controller: "settingsController"
                    },
                    "thirdMenu": {
                        template: empty_template
                    }
                }
            })
            .state("cabinet", {
            url: "/cabinet",
            views: {
                "secondMenu": {
                    templateUrl: "second_menu.html?parent=cabinet",
                    controller: "cabinetController"
                },
                "thirdMenu": {
                    template: empty_template
                }
            }
        })

But only part of my menu i need work with angular. Other part of menu must go to static (not angular) url of my site, like this:

<ul>
    <li><a href="/static-url/">static-url</a></li>
    <li><a ui-sref="cabinet">cabinet angular url</a></li>
    <li><a ui-sref="settings">settings angular</a></li>
</ul>

And when i click on angular-urls - i get need information in my ng-view , but if after then i click on static-url - my url changing from /#/cabinet (for ex.) to /static-url/, but query to server does not exist. Page content saving as in cabinet angular url.

How I can disabling angular ui-router working on /static-url/ ?


回答1:


So for future lurkers, here's what you need to do. Just add this attribute to your static page's anchor tag:

target="_self"

Like this:

<ul>
    <li><a href="/static-url/" target="_self">static-url</a></li>
    <li><a ui-sref="cabinet">cabinet angular url</a></li>
    <li><a ui-sref="settings">settings angular</a></li>
</ul>


来源:https://stackoverflow.com/questions/24822043/how-to-disable-static-url-in-angular-ui-router

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