状态转换Angular ui-router?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (52)

只想通过拒绝承诺并运行来重定向到另一种状态$state.go('state');

简单地说:

deferred.reject();
$state.go('state',{params: 'param'});
提问于
用户回答回答于

deferred.reject()只需通知deferred.promise

var promise = deferred.promise;

promise.then(
  function (result) { 
    // this function runs if the promise was resolved
  },
  function (result) {
    // this function runs if the promise was rejected
    // this is where you should put $state.go(..)
  }
)

扫码关注云+社区

领取腾讯云代金券