2016-06-21 20 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不是。

这解决了这个问题。