UI的SREF不会产生在URL哈希(角1.3.0-rc.3) [英] Ui-sref not generating hash in URL (Angular 1.3.0-rc.3)

查看:151
本文介绍了UI的SREF不会产生在URL哈希(角1.3.0-rc.3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于从角1.3.0 RC-2升级到RC-3通过与UI SREF产生链接中的哈希符号已经消失了。链接是可以点击的,状态转移正确执行,但如果我复制链接地址,并将其粘贴在浏览器将登陆错误的网页上。我不想使用HTML5Mode。

Since upgrading from Angular 1.3.0 RC-2 to RC-3 the hash-sign in my links generated by ui-sref has disappeared. The link is clickable and the state transfers happens correctly, but if i copy the link address and paste it in a browser it will land on the wrong page. I dont want to use HTML5Mode.

1.3.0-rc.2

1.3.0-rc.2

    <!DOCTYPE html>
    <html>

      <head>
        <link rel="stylesheet" href="style.css">
      </head>

      <body ng-app="myApp">

        <div ui-view></div>
        <script src="https://code.angularjs.org/1.3.0-rc.2/angular.js"></script>
        <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script>
        <script>
          angular.module('myApp', ['ui.router'])
          .config(function($stateProvider, $urlRouterProvider, $locationProvider) {


            $urlRouterProvider.otherwise('/foo');

            $stateProvider.state('foo', {
              url: '/foo',
              template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>'
            })
            .state('foo.bar', {
              url: '/bar',
              template: 'This is bar'
            })

            $locationProvider.html5Mode(false);
            //$locationProvider.html5Mode({ enabled: false })
          });
        </script>

      </body>

    </html>

Plunkr示范工作的例子

1.3.0-rc.4

1.3.0-rc.4

    <!DOCTYPE html>
    <html>

      <head>
        <link rel="stylesheet" href="style.css">
      </head>

      <body ng-app="myApp">

        <div ui-view></div>
        <script src="https://code.angularjs.org/1.3.0-rc.4/angular.js"></script>
        <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script>
        <script>
          angular.module('myApp', ['ui.router'])
          .config(function($stateProvider, $urlRouterProvider, $locationProvider) {


            $urlRouterProvider.otherwise('/foo');

            $stateProvider.state('foo', {
              url: '/foo',
              template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>'
            })
            .state('foo.bar', {
              url: '/bar',
              template: 'This is bar'
            })

            //$locationProvider.html5Mode(false);
            $locationProvider.html5Mode({ enabled: false })
          });
        </script>

      </body>

    </html>

Plunkr证明问题

我做得不对,或者是UI的路由器角最新发布候选?

Am i doing something wrong, or is ui-router not compatible with the latest release candidate of Angular?

推荐答案

这是一个已知的问题。它的固定在
<一href=\"https://github.com/angular-ui/ui-router/issues/1397\">https://github.com/angular-ui/ui-router/issues/1397

That's a known issue. It's fixed in master. https://github.com/angular-ui/ui-router/issues/1397

角1.3改变了HTML5模式API和UI的路由器有可支持API。

Angular 1.3 changed the HTML5 mode API, and UI-Router has to support either API.

这篇关于UI的SREF不会产生在URL哈希(角1.3.0-rc.3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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