angularjs UI路由器位置路径不能识别向前slahes [英] angularjs ui-router location path not recognizing the forward slahes

查看:253
本文介绍了angularjs UI路由器位置路径不能识别向前slahes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用角UI路由器/ stateProvider 。不过,我建立了我的网址第二斜杠之后的任何部分被忽略,它总是发送到这个状态:

I'm using angular ui router / stateProvider. However I set up my url any parts after the second forward slash is ignored and it always sends to this state:

  $stateProvider.state('board', {
    url: "/:board",
    views: {
      'content': {
        templateUrl: '/tmpl/board',
        controller: function($scope, $stateParams, $location) {
          console.log('wat')
          console.log($location)
        }
      }
    }
  });

其中只有1个正斜杠。甚至当我去本地主机/联系人/航空自卫队下面的状态不运行。

$ stateProvider.state('测试',{
    网址:/联系人/ ASDF
    观点:{
      '主':{
        templateUrl:'/ TMPL /联系人/ ASDF,
        控制器:功能(){
          的console.log('这并不在这里工作)
        }
      }
    }
  });

$stateProvider.state('test', { url: "/contacts/asdf", views: { 'main': { templateUrl: '/tmpl/contacts/asdf', controller: function () { console.log('this doesnt work here') } } } });


这是$位置的控制台日志。正如你所看到的$ location只能识别URL作为路径的最后一部分。至于我可以告诉大家,是错误的。它遗漏了其之前的人脉。任何URL是PTED仅具有1的URL零件间$ P $和发送到状态。我该如何解决这个问题。谢谢。

This is a console log of $location. As you can see $location only recognizes the last part of the url as the path. As far as I can tell that's wrong. It's missing the "contacts" right before it. Any url is interpreted as having only 1 part for the url and sends to the board state. How do I fix this. THanks.

编辑:发现这是由角1.1.5引起的。回复到1.1.4没有这个。

found that this was caused by angular 1.1.5. Reverting back to 1.1.4 didn't have this.

推荐答案

这可能是原因:的 https://github.com/angular/angular.js/issues/2799 。尝试添加一个基本href。

This may be the cause: https://github.com/angular/angular.js/issues/2799 . Try adding a base href.

这篇关于angularjs UI路由器位置路径不能识别向前slahes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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