UI的路由器不生产的角度正确的href属性路由器、属性、角度、正确

2023-09-14 00:19:45 作者:硬汉i

  $ stateProvider  .STATE('管理员',{    摘要:真实,    网址:'/管理员',    模板:'<格UI的视图>< / DIV>'  })<一个UI的SREF =admin的>联系< / A> 

我得到的网址是< A HREF =/ admin的>联系< / A> 时,它的应的是 /#/管理员 - 这打破了,当我命令点击一个链接在新标签页中打开

解决方案

这是一个已知的问题,报告中的错误。将固定在明年发布。这里是一个解决方法:

不可能禁用与角1.3.0-rc.3#1397

  

由于:

    用几行代码管理几十种网络设备

angular/angular.js@dc3de7f

    

在html5mode检查中urlRouter.js [行383]不再正确。因此它是不可能禁用html5mode。

    

一个速战速决可能是:

  VAR isHtml5 = $ locationProvider.html5Mode();如果(angular.isObject(isHtml5)){  isHtml5 = isHtml5.enabled;} 

也有是克里斯牛逼的( UI-路由器组成员)的 - 下方看到这个 Q&放意见;一个

  

使用了pre-发行版本0.2.12- pre1现在。 bit.ly/UIR-0212$p$p1 ......它有一些修正为1.3.0 COMPAT。克里斯 - ŧ10月16日16:13时。

$stateProvider
  .state('admin', {
    abstract: true,
    url: '/admin',
    template: '<div ui-view></div>'
  })


<a ui-sref="admin">admin</a>

The url I get is <a href="/admin">admin</a> when it should be /#/admin -- this breaks when I command click on a link to open in a new tab.

解决方案

This is a known issue, reported as a bug. Will be fixed in next release. Here is a workaround:

Impossible to disable html5Mode with angular 1.3.0-rc.3 #1397

Due to:

angular/angular.js@dc3de7f

the html5mode-check in urlRouter.js [line 383] is no longer correct. And thus it's impossible to disable html5mode.

A quick fix could be:

var isHtml5 = $locationProvider.html5Mode();
if (angular.isObject(isHtml5)) {
  isHtml5 = isHtml5.enabled;
}

Also there is suggestion by Chris T (UI-Router team member) - see comments under this Q & A

Use the pre-release version 0.2.12-pre1 for now. bit.ly/UIR-0212pre1 ... it has a few fixes for 1.3.0 compat. – Chris T Oct 16 at 16:13