How to redirect in a ui-router resolver?

前端 未结 7 705
我寻月下人不归
我寻月下人不归 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

    I use this

       function Check($state, $q) {
            var deferred = $q.defer();
            if (condition) {
                deferred.resolve();
            }
            else {
                deferred.reject();
            }
            return deferred.promise.catch(function () { $state.go('path'); });
        }
    

提交回复
热议问题