'ngx-avatar' 不是已知元素

'ngx-avatar' is not a known element

我在使用 ngx-avatar 时遇到这些错误

未捕获的错误:模板解析错误:

'ngx-avatar' is not a known element:

1. If 'ngx-avatar' is an Angular component, then verify that it is part of this module.
2. If 'ngx-avatar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

("

[ERROR ->]<ngx-avatar name="John Doe"></ngx-avatar>

"):

ng:///CardDetailsModule/CardDetailsComponent.html@118:6
    at syntaxError (compiler.js:2175)
    at TemplateParser.parse (compiler.js:11388)
    at JitCompiler._parseTemplate (compiler.js:25963)
    at JitCompiler._compileTemplate (compiler.js:25951)
    at compiler.js:25895
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (compiler.js:25895)
    at compiler.js:25808
    at Object.then (compiler.js:2166)
    at JitCompiler._compileModuleAndComponents (compiler.js:25807)

我已将这些包含在 app.module.ts

import { AvatarModule } from 'ngx-avatar';

。 . .

imports: [...,AvatarModule]

我已经全局安装了 ngx,但它仍然无法正常工作

我认为您的项目中有两个模块

  • 应用模块
  • CardDetails 模块

ngx-avatar用于cardsDetailComponent,属于CardDetails Module。但是你已经在 app.module.

中导入了 ngx-avatar

尝试在cardDetails.module和check.Suppose中导入ngx-avatar模块,如果你跨多个模块使用ngx-avatar意味着移动它到共享模块并将其导入到需要的模块

将 ngx-avatar 导入 cardDetails.module 后,确保将其从 app.module

中删除