我正在使用 Angular 1.4.8 和 Angular ui-router 0.2.18
我的配置:
$stateProvider
.state('searchScreen', {
url:'/offers/:mode?id',
templateUrl: 'offerssearch',
controller: 'SearchController as search'
})
我想要做的是用按钮绑定(bind)一个改变url的函数,这是我的函数:
search.createLink = function () {
$state.go('searchScreen', {url:'/offers/link?id=234'});
}
我希望函数调用后我的 URL 看起来像这样:
http://localhost:8080/#/offers/link?id=234
但是 /offers/link?id=234
没有出现在我的 URL http://localhost:8080/#/offers/
最佳答案
没有测试,但我认为你需要将代码更改为:
$state.go('searchScreen', { 'mode':'link', 'id': 234});
关于angularjs - Angular ui-router $state 更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36340729/