Angular 角2:模块链的中断在哪里?

Angular 角2:模块链的中断在哪里?,angular,typescript,angular2-modules,Angular,Typescript,Angular2 Modules,我有一个正在呼叫的模块home.module,我已将其路由到根文件夹中的app.module。随着事情的不断发展,home.module变得越来越庞大。当然,我会创建更多的模块来进行分支,但由于某些原因,没有定义组件 到目前为止,这里是模块的布局 home.模块 import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/p

我有一个正在呼叫的模块
home.module
,我已将其路由到根文件夹中的
app.module
。随着事情的不断发展,
home.module
变得越来越庞大。当然,我会创建更多的模块来进行分支,但由于某些原因,没有定义组件

到目前为止,这里是模块的布局

home.模块

import { NgModule }                     from '@angular/core';
import { BrowserModule }                from '@angular/platform-browser';

import { HomeRoutingModule }            from './home-routing.module';

import { HomeComponent }                from './home.component';
import { HomeIntroComponent }           from './intro/home-intro.component';
import { ExpandBusinessComponent }      from './expand/exp-business.component';
import { RecreateBusinessComponent }    from './recreate/rec-business.component';
import { NewBusinessComponent }         from './newbus/new-business.component';
import { NewProductComponent }          from './newprod/new-product.component';
import { TechDifficultyComponent }      from './techdif/tech-difficulty.component';


import { KeyPointsModule }              from './keypoints/keypoints.module';



import { PointFormatsComponent }        from './keypoints/formats/point-formats.component';
import { FormatsExpandComponent }       from './keypoints/formats/exp/formats-exp.component';
import { FormatsNewBusComponent }       from './keypoints/formats/new/formats-newb.component';
import { FormatsRebrandComponent }      from './keypoints/formats/rebr/formats-rebr.component';

import { PointNicheComponent }          from './keypoints/niches/point-niche.component';
import { PointSimplifyComponent }       from './keypoints/simplifying/point-simplify.component';
import { PointSizeComponent }           from './keypoints/sizing/point-sizing.component';

import { PointFreshStartComponent }     from './keypoints/freshstart/point-fresh-start.component';
import { FreshStartNewBusComponent }    from './keypoints/freshstart/new/fresh-newb.component';
import { FreshStartRebrandComponent }   from './keypoints/freshstart/rebr/fresh-rebr.component';

import { PointInhouseComponent }        from './keypoints/inhouse/point-inhouse.component';
import { PointRemixComponent }          from './keypoints/remix/point-remix.component';
import { PointUiUxComponent }           from './keypoints/uiux/point-uiux.component';

@NgModule({
    imports:[
        BrowserModule,
        HomeRoutingModule,
        KeyPointsModule //<-- this is what I'm injecting to inject everything from
                        //    PointFormatsComponent on down.
    ],
    declarations:[

        //This will stay here as is.
        HomeComponent,
            HomeIntroComponent, ExpandBusinessComponent, RecreateBusinessComponent,
            NewBusinessComponent, NewProductComponent, TechDifficultyComponent,

        //These are what I'm converting into modules to inject
        //into the KeyPointsModule.
        PointFormatsComponent,
            FormatsExpandComponent, FormatsNewBusComponent, FormatsRebrandComponent,

        PointFreshStartComponent,
            FreshStartRebrandComponent, FreshStartNewBusComponent,

        //These are the groups left to expand upon in the same way
        //as the PointFormats and PointFreshStart components.
        PointNicheComponent,
        PointSimplifyComponent,
        PointSizeComponent,
        PointInhouseComponent,
        PointRemixComponent,
        PointUiUxComponent
    ],

    bootstrap: [ HomeComponent ]

})

export class HomeModule {

}
import { NgModule }         from '@angular/core';
import { BrowserModule }    from '@angular/platform-browser';

import { AssetsModule }     from './assets/point-assets.module';

@NgModule({
    imports:[
        BrowserModule,
        AssetsModule //<-- Module for one of the groups of components
                     //I already eliminated from the home.module
    ]
    //This module is more about being a "wire" for things to pass through
    //rather than something with functionality so I didn't set any
    //declarations or bootstrap components.
})

export class KeyPointsModule {

}
import { NgModule }                     from '@angular/core';
import { BrowserModule }                from '@angular/platform-browser';

import { PointAssetsComponent }         from './point-assets.component';

import { AssetExpandComponent }         from './exp/asset-exp.component';
import { AssetNewBusComponent }         from './new/asset-newb.component';
import { AssetRebrandComponent }        from './rebr/asset-rebr.component';

@NgModule({
    imports:[ BrowserModule ],
    declarations: [

        //These are the components I eliminated from the home.module
        PointAssetsComponent,
        AssetExpandComponent,
        AssetNewBusComponent,
        AssetRebrandComponent
    ],
    bootstrap: [ PointAssetsComponent ]
})

export class AssetsModule {

}
点资产模块

import { NgModule }                     from '@angular/core';
import { BrowserModule }                from '@angular/platform-browser';

import { HomeRoutingModule }            from './home-routing.module';

import { HomeComponent }                from './home.component';
import { HomeIntroComponent }           from './intro/home-intro.component';
import { ExpandBusinessComponent }      from './expand/exp-business.component';
import { RecreateBusinessComponent }    from './recreate/rec-business.component';
import { NewBusinessComponent }         from './newbus/new-business.component';
import { NewProductComponent }          from './newprod/new-product.component';
import { TechDifficultyComponent }      from './techdif/tech-difficulty.component';


import { KeyPointsModule }              from './keypoints/keypoints.module';



import { PointFormatsComponent }        from './keypoints/formats/point-formats.component';
import { FormatsExpandComponent }       from './keypoints/formats/exp/formats-exp.component';
import { FormatsNewBusComponent }       from './keypoints/formats/new/formats-newb.component';
import { FormatsRebrandComponent }      from './keypoints/formats/rebr/formats-rebr.component';

import { PointNicheComponent }          from './keypoints/niches/point-niche.component';
import { PointSimplifyComponent }       from './keypoints/simplifying/point-simplify.component';
import { PointSizeComponent }           from './keypoints/sizing/point-sizing.component';

import { PointFreshStartComponent }     from './keypoints/freshstart/point-fresh-start.component';
import { FreshStartNewBusComponent }    from './keypoints/freshstart/new/fresh-newb.component';
import { FreshStartRebrandComponent }   from './keypoints/freshstart/rebr/fresh-rebr.component';

import { PointInhouseComponent }        from './keypoints/inhouse/point-inhouse.component';
import { PointRemixComponent }          from './keypoints/remix/point-remix.component';
import { PointUiUxComponent }           from './keypoints/uiux/point-uiux.component';

@NgModule({
    imports:[
        BrowserModule,
        HomeRoutingModule,
        KeyPointsModule //<-- this is what I'm injecting to inject everything from
                        //    PointFormatsComponent on down.
    ],
    declarations:[

        //This will stay here as is.
        HomeComponent,
            HomeIntroComponent, ExpandBusinessComponent, RecreateBusinessComponent,
            NewBusinessComponent, NewProductComponent, TechDifficultyComponent,

        //These are what I'm converting into modules to inject
        //into the KeyPointsModule.
        PointFormatsComponent,
            FormatsExpandComponent, FormatsNewBusComponent, FormatsRebrandComponent,

        PointFreshStartComponent,
            FreshStartRebrandComponent, FreshStartNewBusComponent,

        //These are the groups left to expand upon in the same way
        //as the PointFormats and PointFreshStart components.
        PointNicheComponent,
        PointSimplifyComponent,
        PointSizeComponent,
        PointInhouseComponent,
        PointRemixComponent,
        PointUiUxComponent
    ],

    bootstrap: [ HomeComponent ]

})

export class HomeModule {

}
import { NgModule }         from '@angular/core';
import { BrowserModule }    from '@angular/platform-browser';

import { AssetsModule }     from './assets/point-assets.module';

@NgModule({
    imports:[
        BrowserModule,
        AssetsModule //<-- Module for one of the groups of components
                     //I already eliminated from the home.module
    ]
    //This module is more about being a "wire" for things to pass through
    //rather than something with functionality so I didn't set any
    //declarations or bootstrap components.
})

export class KeyPointsModule {

}
import { NgModule }                     from '@angular/core';
import { BrowserModule }                from '@angular/platform-browser';

import { PointAssetsComponent }         from './point-assets.component';

import { AssetExpandComponent }         from './exp/asset-exp.component';
import { AssetNewBusComponent }         from './new/asset-newb.component';
import { AssetRebrandComponent }        from './rebr/asset-rebr.component';

@NgModule({
    imports:[ BrowserModule ],
    declarations: [

        //These are the components I eliminated from the home.module
        PointAssetsComponent,
        AssetExpandComponent,
        AssetNewBusComponent,
        AssetRebrandComponent
    ],
    bootstrap: [ PointAssetsComponent ]
})

export class AssetsModule {

}
当所有东西都放在
home.module
中时,所有东西都显示得非常完美,但现在我创建了
kepoints.module
point assets.module
,浏览器突然无法识别组件上的选择器,这意味着它没有在链中正确定义

到目前为止,我一直在使用它将
点资产.module
直接链接到
主.module
,以查看它是否有问题,并且可以肯定的是,我在识别随模块导入的选择器时遇到了一个错误。我一直在反复检查,看看我是否意外地在某处导入了
com设备
modLUe
,但我的眼睛没有注意到它


注入到
关键点.module
中的组件不是将在浏览器中路由到的任何组件,因此我不需要创建或导入任何路由。它们只需在组件视图内部通过
*ngIf
开关,具体取决于它们所处的路径。看到在这一点之前一切都很好,我认识到这个错误是一个模块化的问题,我在没有必要添加所有其他文件并发布整个错误消息之前已经解决了这个问题,但是如果需要,请告诉我,我会用这些信息更新帖子。

我认为您还需要
导出模块声明中的组件。如果你在应用程序中只使用
KeyPointsModule
,你也只能使用从那里导出的组件,而不能使用导入
KeyPointsModule
的组件。您或者需要将
AssetsModule
也导入到应用程序中,或者从
KeyPointsModule
重新导入它。是的,这很有效。我必须导出
AssetsModule
中的每个组件,然后在
KeyPointsModule
中,只需导入
KeyPointsModule
即可导入和导出整个
AssetsModule
并将其传递到
HomeModule
。谢谢!!!:)好的,我刚刚将下一个模块添加到
KeypointsModule
中,但它无法识别新模块。回到原点,哈哈。