angularjs - Angular ui-router $state 更改 URL

标签 angularjs angular-ui-router

我正在使用 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/

相关文章:

angularjs - Angular View 在 http 拦截器之后不会更新

javascript - 无法存储使用 Angular.js UI Router 构建的多步骤表单的数据

javascript - AngularJS - 如何覆盖 $urlRouterProvider.when

javascript - 从 typescript 中的数据填充列中的索引值(Angular/React)

javascript - 粗箭头函数抛出错误 "expression expected"

angularjs - 如何使用 angular-ui-router v0.2.5(允许模块)在单独的 View 中使用全局页脚

javascript - 在 Angular 身份验证中显示当前用户名

当 ng-show 为 false 时,AngularJS 动画不会立即停止

angularjs - Protractor sendKeys 不向文本框发送任何内容

AngularJS ngRoute 不工作