2016-01-13 78 views
0

我正在创建一个简单的angularjs应用程序,并且想要读取URL mypath.com/test.html?param1=test的查询参数。如何读取angularjs中的url查询参数?

问题:如何读取和修改参数列表?

$location.search()此处不返回任何结果。

+0

等什么_does_'$ location.search()'返回? – Alnitak

+0

'[Object object]'不能被检查。 – membersound

+0

以及如果你'console.log(Object.keys($ location.search()))'? – Alnitak

回答

1

我认为你必须在调用之前激活html5Mode:$ location.search()

$locationProvider.html5Mode(true); 
+1

或使用网址# –

+0

你可以添加一个例子如何直接在'test.html'上引用时使用'#'的URL吗?听起来很有希望。 – membersound