2013-02-07 40 views
3

我的應用似乎在Chrome和FF中工作正常,但在IE中,路由存在問題。angular.js IE路由問題

如果我聲明我的應用程序如下

var app = angular.module('category', ['ngSanitize', 'ui']); 

存在於所有

然而

沒有問題,如果我改變了,包括路由定義這樣

var app = angular.module('category', ['ngSanitize', 'ui']). 
    config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { 
    $routeProvider. 
    when('/cat/', {templateUrl: '/category.inc.php', controller: 'CategoryProductsCtrl'}). 
    when('/cat/:colour_title/', {templateUrl: '/category.inc.php', controller: 'CategoryProductsCtrl'}); 
}]); 

IE增加了#在地址欄中的貓之前,所以不要像

example.com/cat/

它顯示

example.com/#/cat/

在IE控制檯我收到以下錯誤

錯誤:10 $摘要()迭代到達。中止! ([fn:function(){var a = d.url(),b = ..............

我已經在最後5次迭代中解僱了通過這裏的步驟

http://docs.angularjs.org/guide/ie

和我,包括

JSON2, 角-UI-ieshiv.min.js html5shim.js(使它在IE7工作)

匆匆在我的應用程序中沒有使用ant自定義標籤等任何幫助將不勝感激。我的應用程序實際上是在相同的狀態,這雖然我是從服務器

http://docs.angularjs.org/tutorial/step_07

+1

關於此問題的討論:https://groups.google.com/forum/#!msg/angular/XujWvUl0nXg/ryyB-nZpdAYJ – Casey

回答

0

你可能設置HTML5模式,以真正在你的路由器配置拉着我的數據,並從刪除「#」網址例如:url: 'http://your_site.com/page/home'

像這樣..

app.config: $locationProvider.html5Mode = true; 
index.html: <base href="root_directory_here" /> 

[more info hereAnd here]