小编sar*_*wc5的帖子

rxjs:EmptyError:序列中没有元素

我收到了一个错误

当我转到localhost:8080时,'EmptyError:序列中没有元素'错误.

我看到了线程Angular 5 EmptyError:在制作子路由时没有顺序的元素,但似乎没有任何答案适用.

我有"rxjs": "^5.5.6",在我的路线中,我尝试添加,pathMatch: 'full',但仍然显示错误.

我的app-routing-module.ts的摘录

const routes: Routes = [
    {
        pathMatch: 'full', /* added recently for test purposes*/
        path: '',
        component: RootComponent,
        canActivate: [AuthGuard],
        children: [
            {
                pathMatch: 'full', /* added recently for test purposes*/
                path: '',
                component: RootLoggedComponent
            },
Run Code Online (Sandbox Code Playgroud)

这只发生在最近,我添加了一个http拦截器:

export class myInterceptor implements HttpInterceptor {
    constructor(
        private router: Router
    ) {

    }

    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

        return next.handle(request)
            .pipe(catchError(err => {
                if (err …
Run Code Online (Sandbox Code Playgroud)

rxjs angular angular6

8
推荐指数
1
解决办法
2480
查看次数

在角度小吃店中居中文本

在有角度的小吃店中居中文本的正确方法是什么?

我试过这个,这不起作用:

let config = new MatSnackBarConfig();
config.panelClass = 'center';
this.snackBar.open(message, undefined, config);
Run Code Online (Sandbox Code Playgroud)

然后在一些 css 文件中(在同一个组件中,或者在全局文件中):

.center {
   justify-content: center;
}
Run Code Online (Sandbox Code Playgroud)

angular-material2 angular angular5

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

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万
查看次数