2016-06-21 19 views
2

我試圖使用$locationangular.js提供queryparams。我的下面的代碼在Firefox中完美工作,但在Internet Explorer 11中不起作用。如果我刪除$location代碼,那麼它的工作原理。

app.config(['$locationProvider', function($locationProvider) { 
    $locationProvider.html5Mode(true); 
}]); 

app.controller('appName', 
     ['$scope', '$location', '$http', function($scope, $location, $http) { 
      alert(JSON.stringify($location)); 
}]); 

的錯誤是很難理解:

Error: Invalid argument. at xa (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9 /angular.min.js:147:373) at hd (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js:97:498) ...

有什麼我做錯了嗎?除了$location.search()之外,還有另外一種方法可以從IE 11中提取queryparams

謝謝!

+0

嘗試添加到您的index.html – Chisko

回答

1

原來的問題是在我的HTML文件:

我以前有:

<base href="appname"> 

我需要這個更改爲:

<base href="/appname/"> 

火狐是寬容的缺失'/',但IE不是。

這解決了這個問題。