如何找到Angular应用的某个directive是属于哪一个Angular module
Suppose I would like to use SAP Spartacus directive cxComponentWrapper in my custom Component,and error message is:
Can’t bind to ‘cxComponentWrapper’ since it isn’t a known property of ‘ng-container’.\n1.
This is caused by missing import. However, how can we know which module should be imported from where?
The tip is to check it out in SAP Spartacus source code. Suppose you have already cloned it from github: https://github.com/SAP/spartacus
search source code by keyword “cxComponentWrapper”, there should be plenty of hits, for example tab-paragraph-container.component.html:
I am using Visual Studio Code for Spartacus development, and installed the plugin Angular Language Service:
With this plugin, simply press Ctrl + mouse left click, to automatically navigate to implementation part of cxComponentWrapper directive, it’s here:
Here we can know cxComponentWrapper directive is exported via module : PageComponentDirective:
As a result, in my application module, just add PageComponentModule into app module’s imports section, and the error is gone:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的如何找到Angular应用的某个directive是属于哪一个Angular module的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 航天模拟器怎么发射(中国载人航天官方网站
- 下一篇: 年度最佳:《塞尔达传说:王国之泪》M 站