UI的路由器不生产的角度正确的href属性 [英] ui-router not producing correct href attribute in angular

查看:133
本文介绍了UI的路由器不生产的角度正确的href属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ 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-路由器<建议/ code>组成员)的 - 下方看到这个 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

这篇关于UI的路由器不生产的角度正确的href属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆