How can i update $stateParams without reloading the ui-view? angular ui router

后端 未结 3 808
無奈伤痛
無奈伤痛 2020-12-15 17:02

Get the context, angular, ui-router, nothing special, a root view built with 3 named ui-views. so in index.html we have


  
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 17:56

    Quoting @christopherthielen from https://github.com/angular-ui/ui-router/issues/1758#issuecomment-205060258:

    using notify: false is almost never a good idea, and is now deprecated. Use reloadOnSearch if you must.

    You can also try dynamic parameters in the 1.0 version (currently 1.0.0-alpha.3). In your state, configure a parameter as dynamic and implement the uiOnParamsChanged callback :

    .state('foo', {
      url: '/:fooId',
      params: { fooId: { dynamic: true } },
      controller: function() {
        this.uiOnParamsChanged = function(changedParams, $transition$) {
          // do something with the changed params
          // you can inspect $transition$ to see the what triggered the dynamic params change.
        }
      }
    });
    

    For a demo, have a look at this plunker: http://plnkr.co/edit/T2scUAq0ljnZhPqkIshB?p=preview

提交回复
热议问题