How to redirect in a ui-router resolver?

前端 未结 7 710
我寻月下人不归
我寻月下人不归 2021-02-03 17:58

I am trying to redirect inside a ui-router resolve and wanted to know if there is a way to reroute in a router resolver. Currently this does not work as one would think.

7条回答
  •  借酒劲吻你
    2021-02-03 18:49

    You can use resolver promises from with the redirectTo configuration

       redirectTo: function($transition$) {
          return $transition$.injector().getAsync('isNew').then(function(isNew) {
            return isNew ? 'estate.edit' : 'estate.view';
          });
        },
    

提交回复
热议问题