当我拒绝承诺时,此错误将显示在控制台上。 IN CONSOLE: EXCEPTION:未捕获(在承诺中):null error_handler.js:56 原装STACKTRACE: 错误:未捕获(承诺):null
@Injectable()
export class PaymentScheduleResolve implements Resolve<any> {
constructor(private rtoService: RtoService,
private rtoActivationService: RtoActivationService,
private router:Router,
private toastr: Toastr) {
}
resolve() {
var self = this;
return new Promise((resolve, reject) => {
let rtoInfo = self.rtoActivationService.getRtoInfo();
if (!rtoInfo) {
reject("null");// This will produce error on console
}
else{
self.rtoActivationService.getPaymentSchedules(rtoInfo.Id, rtoInfo.Data.RtoRentLength)
.then((res: any) => {
if (res.Response && res.Response.Code === 200) {
resolve(res.Response.Data);
}
else {
reject(null);// This will produce error on console
}
})
.catch((err: any) => {
console.log(err);
reject(null);// This will produce error on console
})
}
});
}
答案 0 :(得分:0)
只需使用
resolve(null);
而不是
reject(null);
答案 1 :(得分:0)
使用以下方法拒绝解析器。这会将您重定向到默认路由。
<android.support.v7.widget.RecyclerView
android:id="@+id/freshRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="vertical" />
或者您可以重定向到错误页面
reject({message: err , ngNavigationCancelingError: true});