AngularJS NG-HREF不走链接 [英] AngularJS ng-href does not go to link
问题描述
我检查的文档和 NG-HREF不工作线程在这里已经但是我难住了。
I've checked the docs and the ng-href not working thread on here already but I'm stumped.
请问NG-HREF需要一个完整的路径?目前,矿山看起来像<一个NG-标题={{title.text}}NG-ID ={{id.num}}NG-HREF =/ page.php#参数:{{id.num}}><跨度>转到此处< / SPAN>< / A>
,但是当我点击它,而它在地址栏中的URL改变正确的浏览器(和它的一个合法URL;我打在地址栏中输入,它会去那里),它实际上并没有进入该页面。
Does ng-href require a full path? Mine currently looks like <a ng-title="{{title.text}}" ng-id="{{id.num}}" ng-href="/page.php#param:{{id.num}}"><span>go here</span></a>
, but when I click on it, while it changes the URL in the address bar of the browser correctly (and it's a legitimate URL; I can hit "enter" in the address bar and it will "go there"), it does not actually GO TO that page.
什么错?我需要这与某种NG-点击
结合?如果是这样,为什么?
What's going wrong? Do I need to combine this with an ng-click
of some sort? And if so, why?
更新:该链接会从它被调用的相同的网页,但对于不同的数据记录显示不同的参数。我认为,可能有一些用它做...
UPDATE: The link is going to the same page from which it is being called, but with a different parameter for a different data record display. I think that may have something to do with it ...
推荐答案
下面是我如何结束了解决这一之一:
Here is how I ended up solving this one:
模板:
<a ng-title="{{title.text}}" ng-id="{{id.num}}" ng-click="go_to_item(id.num)">
<span>{{title.text}}</span>
</a>
使用Javascript:
Javascript:
$scope.go_to_item = function(display) {
window.location = '/page.php#id:' + display;
location.reload();
};
这是工作,因为它应该在我们的应用程序。为什么角具体 $位置
和 $窗口
的不的的工作有一个神秘的我,虽然。我想那些第一和他们没有这样做,因此,如果任何人都可以解释为什么,我给你接受的答案这个问题! ; - )
This is working as it should in our app. Why the Angular-specific $location
and $window
don't work there is a mystery to me, though. I tried those first and they didn't do it, so if anyone can explain why, I'll give you "accept answer" for this question! ;-)
这篇关于AngularJS NG-HREF不走链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!