相关疑难解决方法(0)

Angular 5 EmptyError:在创建子路由时没有顺序元素

当我在路由中使用子项时,我无法从登录页面导航到仪表板页面,如下所示:

const appRoutes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent,pathMatch: 'full' },
{
  path: 'dashboard',pathMatch: 'full', /* canActivate: [AuthGuard], */ component: DashboardComponent , 
  children: [
    {
      path: 'online-submission/:moduleName',pathMatch: 'full', component: OnlineSubmissionComponent, 
      /* canActivate: [AuthGuard], */data:{
          breadcrumb: "online-submission"
      } ,
      children: [
        { path: 'batch-upload-members',pathMatch: 'full', component: BatchUploadMembersComponent, 
        /* canActivate: [AuthGuard], */data:{
            breadcrumb: "batch-upload-members"
        } },
        { path: 'select-members',pathMatch: 'full', component: SelectMembersComponent, 
        /* canActivate: [AuthGuard], */data:{
            breadcrumb: "select-members"
        } 
       }
      ] 
    } …
Run Code Online (Sandbox Code Playgroud)

routing angular

6
推荐指数
1
解决办法
2979
查看次数

Angular httpClient拦截器错误处理

在阅读了有关http客户端错误处理的有关角度的文档后,我仍然不明白为什么我没有从服务器捕获带有以下代码的401错误:

export class interceptor implements HttpInterceptor {
    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        console.log('this log is printed on the console!');

        return next.handle(request).do(() => (err: any) => {
            console.log('this log isn't');
            if (err instanceof HttpErrorResponse) {
                if (err.status === 401) {
                    console.log('nor this one!');
                }
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

在控制台日志上,我也得到了:

zone.js:2969 GET http:// localhost:8080 / test 401()

core.js:1449错误HttpErrorResponse {标题:HttpHeaders,状态:401,statusText:“确定”,url:“ http:// localhost:8080 / test ”,确定:否,…}

angular-http-interceptors angular angular-httpclient angular6

6
推荐指数
2
解决办法
1万
查看次数