2012-12-02 48 views
3

我有一個應用html5Mode = true,但在IE上我不需要回退到#/ url。我需要的是保持URL並完成一個完整的頁面重新加載。AngularJS + html5Mode +自定義後備

如果我找不到任何方法,我將需要編輯AngularJS文件,這就是我不想要的。

對此提出建議?

謝謝!

- 編輯 -

隨着時間的解決方案我評論在AngularJS文件中的一些代碼。

/*if ($sniffer.history) {*/ 
    $location = new LocationUrl(
     convertToHtml5Url(initUrl, basePath, hashPrefix), 
     pathPrefix, appBaseUrl); 
    /*} else { 
    $location = new LocationHashbangInHtml5Url(
     convertToHashbangUrl(initUrl, basePath, hashPrefix), 
     hashPrefix, appBaseUrl, basePath.substr(pathPrefix.length + 1)); 
    }*/ 

現在它不回落到主題標記URL和Browser.url做出location.href如果瀏覽器不支持歷史API。

+0

你見到我的答案嗎?你覺得它有幫助嗎? – m59

回答

0

我認爲這是做你想做的。如果不是,也許解決方案涉及相同的事件$locationChangeStart

var gate = 1; 
    $scope.$on("$locationChangeStart", function(event, nextLocation, currentLocation) { 
    if ($('html').is('.ie6, .ie7, .ie8')) { 
     if (gate === 0) { //prevent endless location change 
     gate = 1; 
     window.location.href = nextLocation; //reload the page 
     } 
     else { 
     gate = 0; 
     } 
    } 
    }); 

如果你不知道這個過時的歌曲檢查,see this post.

+0

這真的有用嗎?是不是所有的URL都有哈希值? –