首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将MatButton添加到角库(角9)

如何将MatButton添加到角库(角9)
EN

Stack Overflow用户
提问于 2020-02-08 20:24:58
回答 1查看 7.1K关注 0票数 4

我使用命令在一个新的角9项目上生成了一个库

多选择

ng g库

现在我想添加角材料的MatButton,所以我添加了'MatButtonModule‘到库的主要模块。我还在库的package.json中添加了“@角形/材料”:"^9.0.0“作为依赖项,并在ng-package.json中白化了这一点。当我尝试构建库(ng构建多选择)时,它说

代码语言:javascript
复制
Compiling TypeScript sources through ngc
ERROR: node_modules/@angular/material/button/button.d.ts:22:22 - error NG6002: Appears in the NgModule.imports of MultiSelectModule, but could not be resolved to an NgModule class

22 export declare class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple, FocusableOption {
                        ~~~~~~~~~
node_modules/@angular/material/button/button.d.ts:22:22 - error NG6003: Appears in the NgModule.exports of MultiSelectModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class

22 export declare class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple, FocusableOption {
                        ~~~~~~~~~

An unhandled exception occurred: node_modules/@angular/material/button/button.d.ts:22:22 - error NG6002: Appears in the NgModule.imports of MultiSelectModule, but could not be resolved to an NgModule class

22 export declare class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple, FocusableOption {
                        ~~~~~~~~~
node_modules/@angular/material/button/button.d.ts:22:22 - error NG6003: Appears in the NgModule.exports of MultiSelectModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class

22 export declare class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple, FocusableOption {

这就是多选择模块的外观

代码语言:javascript
复制
import { NgModule } from '@angular/core';
import { MultiSelectComponent } from './multi-select.component';
import { MatButton } from '@angular/material/button';
import { FormsModule  } from '@angular/forms';
import { SearchPipe } from './search.pipe';

@NgModule({
      declarations: [MultiSelectComponent, SearchPipe],
      imports: [
        MatButton,
        FormsModule
      ],
      exports: []
    })
 export class MultiSelectModule { }

不用说,没有这个模块,库构建得很好。这看起来有什么问题吗?

EN

回答 1

Stack Overflow用户

发布于 2020-02-08 20:36:20

MultiSelectModule模块中,您要导入MatButton。您应该导入它的模块,MatButtonModule

代码语言:javascript
复制
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';

@NgModule({
  // ...
  imports: [ MatButtonModule ],
  // ...
})
export class MultiSelectModule {}
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60130872

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档