如何在 angular ui-router 中禁用静态 url? [英] How to disable static url in angular ui-router?
问题描述
我的 angular 应用程序中有两个 ui-router states
,效果很好,如下所示:
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
}
}
})
但我的菜单中只有一部分需要使用 angular.菜单的其他部分必须转到我网站的静态(非角度)网址,如下所示:
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>
当我点击 angular-urls - 我在我的 ng-view
中得到需要的信息,但如果之后我点击 static-url
- 我的 url 改变从/#/cabinet
(例如)到/static-url/
,但不存在对服务器的查询.页面内容保存为橱柜角度网址.
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.
如何禁用在 /static-url/
上工作的 angular ui-router ?
How I can disabling angular ui-router working on /static-url/
?
推荐答案
因此,对于未来的潜伏者,您需要执行以下操作.只需将此属性添加到您的静态页面的锚标记:
So for future lurkers, here's what you need to do. Just add this attribute to your static page's anchor tag:
target="_self"
像这样:
<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>
这篇关于如何在 angular ui-router 中禁用静态 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!