首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ui-sref不生成URL中的散列(角1.3.0-rc.3)

Ui-sref不生成URL中的散列(角1.3.0-rc.3)
EN

Stack Overflow用户
提问于 2014-10-06 15:53:05
回答 1查看 1.8K关注 0票数 5

自从从角1.3.0rc-2升级到RC-3,我的链接中由ui-sref生成的散列符号消失了。链接是可点击的,状态传输是正确的,但是如果我复制链接地址并将其粘贴到浏览器中,它就会出现在错误的页面上。我不想使用HTML5Mode。

1.3.0-rc.2

代码语言:javascript
复制
    <!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 demonstrating working example

1.3.0-rc.4

代码语言:javascript
复制
    <!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 demonstrating the problem

是我做错了什么,还是ui-路由器不兼容最新的候选版本的角形?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-06 20:49:48

这是一个众所周知的问题。它是用master修复的。https://github.com/angular-ui/ui-router/issues/1397

角1.3改变了HTML5模式API,UI-路由器必须支持任何一个API.

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26220037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档