1.独立组件:Works
没问题,因为你是懒惰加载StandaloneComponent (standalone: true)
,因为它有StandaloneChildComponent (standalone: true)
在它的导入,它的加载没有任何问题!
2.功能组件:Works
没问题,在FeatureModule
的Imports数组中有StandaloneComponent (standalone: true)
,这意味着我们可以在FeatureComponent的html中将其用作<app-standalone />
3.功能下级组件:不起作用!
问题是,因为没有将FeatureChildComponent (standalone: false)
添加到FeatureModule
的声明数组中,这就是为什么您会得到'app-standalone' is not a known element
的错误.由于StandaloneComponent
存在于FeatureModule
的导入中,我们需要在FeatureModule
中有FeatureChildComponent
个声明才能使用app-standalone
!
特征中的共享组件:不起作用!
问题是,因为没有将SharedComponent (standalone: false)
添加到SharedModule
的声明数组中,这就是您收到'app-standalone' is not a known element
的错误的原因.由于StandaloneComponent
是在SharedModule
的进口中,我们需要在SharedModule
中有SharedComponent
的声明才能使用app-standalone
!
Note: When you have a standalone component, that needs to be used in scenarios other than routing, add it to the imports array of a module/standalone component
!
stackblitz个