'ngx-avatar'不是一个已知元素

问题描述 投票:0回答:1

我在使用ngx头像时遇到这些错误

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

'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,但仍无法正常工作

angular ngx-bootstrap avatar
1个回答
0
投票

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

  • 应用模块
  • CardDetails模块

ngx-avatar在属于CardDetails ModulecardsDetailComponent中使用。但是,您已导入app.module中的ngx头像

尝试在cardDetails.module]中导入ngx-avatar模块并进行检查。假设您正在多个模块中使用ngx-avatar,则意味着将其移动到shared module并将其导入到需要的模块

一旦ngx头像导入到cardDetails.module,请确保将其从app.module

删除
© www.soinside.com 2019 - 2024. All rights reserved.