Angular 2 RC5-不同模块使用的通用组件

珊瑚

LandingComponent在公共库中有一个组件我的应用程序中的几乎所有其他模块都需要使用此组件。

文件结构(在/app文件夹内):

/library
    landing.component.ts
/module1
    mod1.module.ts
    mod11.component.ts
/module2
    mod2.module.ts
    mod21.component.ts
app.module.ts

mod11.component.ts摘录

@Component({
    template: '<landing title="M1C1 title" desc="M1C1 description"></landing>';
})
export class Mod11Component {}

mod21.component.ts摘录

@Component({
    template: '<landing title="M2C1 title" desc="M2C1 description"></landing>';
})
export class Mod11Component {}

我应该如何组织导入和声明/指令使它起作用?我应该为库组件创建模块,然后在其他模块中使用它吗?

亚历克西斯·勒·加尔

https://angular.io/docs/ts/latest/guide/ngmodule.html#!#shared-module

共享模块是您寻求的最佳解决方案!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章