angularjs NG-HREF不工作在IE8工作、NG、angularjs、HREF

2023-09-14 23:06:35 作者:绿帽子哪买的。

我们正在构建一个需要在IE8工作网站(是功能最少),我们得到了一些链接不工作,共同为所有的人都为他们使用NG-的href,而不是HREF工作正常。

We are building a site which needs to work in IE8( be functional at least), and we got some links which doesn't work, common for all of them is that they use ng-href instead of href which works fine.

所以这不起作用:

<a ng-href="/User/Index/{{item.MetaData.Author.Id}}">{{item.MetaData.Author.FullName}}</a>

但这样做的工作:

but this does work:

<a href="/User/Index/{{item.MetaData.Author.Id}}">{{item.MetaData.Author.FullName}}</a>

角度做了之后是绑定的链接看起来是这样的:

After angular has done is bindings the link looks like this:

<a class="ng-binding" href="/User/Index/15143" ng-href="/User/Index/15143" jQuery191021026375357298033="135">Niclas Schumacher <!-- IE fix --></a>

我asssume这是角加入IE修复IE8的。

I asssume that it is angular adding the IE fix for IE8.

其他的事情做哪些棱角做工精细,但它的pretty crusial该链接将工作!

other things made which angular work fine, but its pretty crusial that the links will work!

任何人谁拥有了这个错误,或者知道如何解决它?或者是它所以非常crusial有NG-的href,而不是HREF,使用angularjs什么时候?

anyone who has had this error, or knows how to fix it ? OR is it so VERY crusial to have ng-href instead of href, when using angularjs ?

希望能对你有所帮助,在此先感谢!

Hope you can help, thanks in advance!

推荐答案

遇到(从问题的文字我不知道这是否是一样的)类似的问题。无论哪种方式,这是我的问题,是什么让我的工作:

Encountered a similar problem (from the question's text I'm not sure if it's the same). Either way, here's my problem and what got me working:

问题:

显然有使用HREF或在他们没有得到评估NG-的href(此时我使用1.2.18)[1]在IE8时的问题。

Apparently there are problems when using href or ng-href [1] in IE8 (I am using 1.2.18 at this time) in which they don't get evaluated.

例如:

如果发现角既没有名和A HREF链接,它会自动添加它,为此,一个code,如:

If angular finds a link without both name and a href, it adds it automatically, therefor, a code like:

<a ng-href="redirectTo()">link</a>

将最终为

<a href="" ng-href="redirectTo()">link</a>

和重定向到的baseUrl因(应用程序的第一页),点击后,执行和NG-HREF不会覆盖在HREF值。

and the redirect to baseUrl due to "" (the first page of the application) is performed upon click and the ng-href does not override the value in href.

我使用的伎俩是将链接转换为锚(不依赖有code键更改)

The trick I used was to convert the link to an anchor (to not have to change depending code)

<a name="someRandomName" ng-click="redirectTo()">link</a>

和改变redirectTo的)return语句(做一个重定向(无论是与window.location.href或$ location.path,这取决于所需的URL),而不是简单地返回URL。

and change the return statement of redirectTo() to do a redirect (either with window.location.href or $location.path, depending on the URL needed) instead of simply returning the URL.

[1] ngHref: https://docs.angularjs.org/api/ng /指令/ ngHref

[1] ngHref: https://docs.angularjs.org/api/ng/directive/ngHref

 
精彩推荐
图片推荐