Routing does not work well with HTML5-History-API

一世执手 提交于 2019-12-12 06:48:14

问题


In a mean-stack web application, I use html5mode and have the following code in index.html:

<base href="/" />   
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script src="https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js"></script>

I have defined the following angular-ui-router:

    .state('addinHome', {
        url: '/addin/home',
        template: "home page"
    })
    .state('addinTest', {
        url: '/addin/test',
        template: '<a href="addin/home">one</a>',
        controller: 'TestCtrl'
    })

Then, I go to https://localhost:3000/addin/test, clicking on one leads me to https://localhost:3000/addin/test#%2Faddin%2Fhome, whereas I would want to go to https://localhost:3000/addin/home.

If I don't have office.js and history.js, clicking on one does lead me to https://localhost:3000/addin/home.

Does anyone know how to go to https://localhost:3000/addin/home while keeping office.js and history.js?


回答1:


I found it... just use

template: '<a href="addin/home" target="_self">one</a>'


来源:https://stackoverflow.com/questions/44984905/routing-does-not-work-well-with-html5-history-api

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