该组件不会在Angular2中呈现其视图

时间:2017-03-26 11:13:06

标签: angular typescript components

我的Angular2应用程序中有一个名为grid.module.ts的模块,它位于文件夹网格下。   在此文件夹中,我有一些组件,所有组件都已导入,然后导出到此模块。然后在app.module.ts

中导入此模块

在网格文件夹中,我还有另一个名为grid-router.module.ts的模块,此模块也在gird.module.ts中导入。

grid-router.module.ts如下

<input type="checkbox" name="door[1]">
<input type="checkbox" name="door[2]">...

GridComponent html视图名为grid.component.html,如下所示

import { NgModule } from '@angular/core';
import{RouterModule} from '@angular/router';

import { GridComponent } from '../grid/grid.component';
import {InfoDetailsComponent} from './info-details.component'


@NgModule({

imports : [
component:GridComponent and it will dispalay the html view of GridComponent
 RouterModule.forChild([
   {path: 'grid', component:GridComponent},
   {path:'info/:id',component:InfoDetailsComponent}

   ])

   ],

 exports: [RouterModule]

 })

export class GridRouterModule {
}

info.list.component.ts渲染为其视图info-list.html,如下所示

grid.component.html

// a lot of html here
<div>
<info-ForWidget></info-ForWidget> //this is a selector of Component info-list.component.ts which is in the same level with grid.component.ts
</div>

直到这里一切正常。   现在,当我转到{{info.Name}}并单击那里以显示组件info-details.component的视图时,视图不会呈现。

注意:代码是可以的,因为在我的服务info-service.ts中使用Observable I console.log getInfo(id:number)的方法,并且数据被加载并显示在Web浏览器的控制台中但视图是没有呈现。  我两天都在苦苦挣扎,我找不到任何解决方案,这就是为什么我需要你们的帮助

0 个答案:

没有答案
相关问题