【发布时间】:2017-06-10 02:41:49
【问题描述】:
我正在基于 Angular2 Docs 在 Angular 2 中创建一个解析类,这是我的类
//Angular core
import { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot} from '@angular/router';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/catch'
//Service
import { CategoryService } from '../services/category.services';
//Model
import { Category } from '../model/category.interface';
@Injectable()
export class ListCategoryResolve implements Resolve<Category[]> {
constructor(private categoryService: CategoryService, private router: Router) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):Observable<Category[]> {
return this.categoryService.GetAll();
}
}
此时我该如何处理错误?,例如我的服务已关闭
【问题讨论】: