代码之家  ›  专栏  ›  技术社区  ›  epsilon

两个角度为6的公共组件延迟加载模块

  •  6
  • epsilon  · 技术社区  · 7 年前

    ---app.module
    -------child1.module
    -------child2.module
    

    我使用一个公共组件( app-film app.module ,但角度仍然显示错误

    Can't bind to 'film' since it isn't a known property of 'app-film'.
    1. If 'app-film' is an Angular component and it has 'film' input, then verify that it is part of this module.
    2. If 'app-film' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    

    斯塔克布利茨 https://stackblitz.com/github/ms-dosx86/films

    1 回复  |  直到 7 年前
        1
  •  4
  •   Suren Srapyan    7 年前

    嵌套模块将看不到父模块中定义的组件(该组件导入嵌套模块)。你需要创建一个 SharedModule 这样地

    @NgModule({
       declarations: [ AppFilmComponent ]
       exports: [ AppFilmComponent ]
    })
    export class SharedModule { }
    

    AppFilmComponent 从那个模块然后导入 共享模块

    @NgModule({
       ...
       imports: [ SharedModule ]
       ...
    })
    export class Child1Module { }
    

    @NgModule({
       ...
       imports: [ SharedModule ]
       ...
    })
    export class Child2Module { }
    
    推荐文章