I'm building a website where the account page is an Angular.js single page app. So a normal view would have the URL like localhost:3000/account#/info
我正在建立一个网站,其中帐户页面是Angular.js单页面应用程序。所以普通视图会有像localhost:3000 / account#/ info这样的URL
Now say I have to make Angular handle a URL like localhost:3000/account/?param=value
, how should I set up the router? (I'm using ui-router)
现在说我必须让Angular处理像localhost:3000 / account /?param = value这样的URL,我应该如何设置路由器? (我正在使用ui-router)
I tried something like
我尝试过类似的东西
$stateProvider.state('my-page', {
url: '',
controller: 'MyPageController'
})
but it doesn't work. (It only detects localhost:3000/account?param=value
notice the missing forward slash after account
)
但它不起作用。 (它只检测localhost:3000 / account?param = value注意帐号后丢失的正斜杠)
Does anyone have any ideas? Thanks.
有没有人有任何想法?谢谢。
1 个解决方案
#1
0
Because the query part belongs to the server side URL instead of ui-router
side, you'll need to get it using $window.location.search
.
因为查询部分属于服务器端URL而不是ui-router端,所以您需要使用$ window.location.search来获取它。
Then you can refer here to turn it into an object for further use.
然后你可以在这里引用它把它变成一个对象供进一步使用。
#1
0
Because the query part belongs to the server side URL instead of ui-router
side, you'll need to get it using $window.location.search
.
因为查询部分属于服务器端URL而不是ui-router端,所以您需要使用$ window.location.search来获取它。
Then you can refer here to turn it into an object for further use.
然后你可以在这里引用它把它变成一个对象供进一步使用。