Angular UI Router ignoring HTML5 Mode off

社会主义新天地 提交于 2019-12-24 04:47:21

问题


Angular UI Router is ignoring HTML5Mode(false), and it's rendering links in a way that can't be bookmarked or directly landing upon:

app.js:

$stateProvider
    .state('search', {
      url: '/search',
      views: {
        'main.wrapper': {
          templateUrl: 'views/search.html',
          controller: 'SearchCtrl'
        },
        'navbar': { templateUrl: 'views/search.navbar.html' }
      });

$locationProvider.html5Mode(false);

foo.html:

<a ui-sref="search">Search</a>

Becomes

<a href="/search">Search</a>

Shouldn't it detect it's not on HTML5 Mode and return

<a href="/#/search">Search</a>

回答1:


As indicated by Radim Köhler, this is a bug between angular-ui-router ~0.2.11 and angular 1.3.0.

https://github.com/angular-ui/ui-router/issues/1397



来源:https://stackoverflow.com/questions/26399911/angular-ui-router-ignoring-html5-mode-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!