tom*_*271 5 angular2-directives angular
在RootModule:
@NgModule({
imports: [
ModuleA
],
declarations: [
ScrollToWhen
],
bootstrap: [BootComponent],
})
class RootModule {}
Run Code Online (Sandbox Code Playgroud)
在模块A中的一个组件模板中,我使用了ScrollToWhen,但是我收到了错误:Can't bind to 'scrollToWhen' since it isn't a known property of 'div'.
为什么?
Error: Unexpected directive 'HbClass' imported by the module 'Module'
Gün*_*uer 10
无论是添加ScrollToWhen到的声明ModuleA或将其移动到一个模块,然后可以添加到imports: [...]的ModuleA以使其可在那里.
组件/指令只能在一个模块中列出declarations: [...].然后在要使用此组件/指令的任何位置导入此模块.
对于用于声明指令和管道的模块,您需要将它们设置为exports:
@NgModule({
declarations: [
myDirectives
],
exports: [
myDirectives
]
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9325 次 |
| 最近记录: |