2017-01-10 10 views
1

私は解決の約束を拒否すると、コンソールにこのエラーが表示されます。コンソールで : 例外:(約束で)キャッチされない:ヌルerror_handler.js:56 ORIGINAL STACKTRACE: エラー:(約束で)キャッチされない:ヌル誓約を拒否してサービスとして解決する

@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

角度2.4.1および3.4​​.1ルータのバージョン – Faris

+0

エラーページにリダイレクトすることができますか? –

答えて

0

ちょうど使用

resolve(null); 

代わりの

reject(null); 
0

以下を使用してリゾルバーを拒否します。これにより、デフォルトルートにリダイレクトされます。

reject({message: err , ngNavigationCancelingError: true}); 

それとも、あなたは何を期待し

this.router.navigateByUrl('errorPage'); 
resolve(false); 
関連する問題