小编tof*_*ofu的帖子

类型'""|中不存在属性"错误" 许<任何>"

我正在尝试按照Angular 指南为服务添加一些错误处理.

相关片段:

private handleError (error: Response | any) {
  // In a real world app, you might use a remote logging infrastructure
  let errMsg: string;
  if (error instanceof Response) {
    const body = error.json() || '';
    const err = body.error || JSON.stringify(body);
    errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
  } else {
    errMsg = error.message ? error.message : error.toString();
  }
  console.error(errMsg);
  return Observable.throw(errMsg);
}
Run Code Online (Sandbox Code Playgroud)

但是,我收到一个TypeScript错误:

error TS2339: Property 'error' does not exist on type '"" | Promise<any>'. …

typescript angular

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

“无组件路由不能有命名出口集”

在我的 ng2 应用程序中,我有以下路线:

const modalRoutes: Routes = [{
    path: 'modal_1',
    component: SomeModalComponent,
    outlet: 'modal',
    children: [
        {
            path: 'step_one',
            component: OneSubmodalComponent,
            outlet: 'submodal'
        },
        {
            path: 'step_two',
            component: AnotherSubmodalComponent,
            outlet: 'submodal'
        },
        {
            path: '',
            redirectTo: 'step_one',
            outlet: 'submodal',
            pathMatch: 'full'
        }
    ]
}];
Run Code Online (Sandbox Code Playgroud)

我有一个用于主页内容的未命名的路由器出口,该路由描述了一个模式的路由,该模式被路由到一个命名的出口modal,并且本身包含一个命名的出口submodal

从 Angular 2.2.4 开始,这工作得很好,但更新到 2.3.0+ 后,我现在收到错误Invalid configuration of route 'modal_1/': a componentless route cannot have a named outlet set。我可以看到这是因为重定向路由没有定义组件,但它应该只是重定向到step_one已定义的组件。我这里的路由设计有问题吗?

angular2-routing angular

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

标签 统计

angular ×2

angular2-routing ×1

typescript ×1