我使用命令在一个新的角9项目上生成了一个库
多选择
ng g库
现在我想添加角材料的MatButton,所以我添加了'MatButtonModule‘到库的主要模块。我还在库的package.json中添加了“@角形/材料”:"^9.0.0“作为依赖项,并在ng-package.json中白化了这一点。当我尝试构建库(ng构建多选择)时,它说
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 {这就是多选择模块的外观
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 { }不用说,没有这个模块,库构建得很好。这看起来有什么问题吗?
发布于 2020-02-08 20:36:20
在MultiSelectModule模块中,您要导入MatButton。您应该导入它的模块,MatButtonModule。
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
// ...
imports: [ MatButtonModule ],
// ...
})
export class MultiSelectModule {}https://stackoverflow.com/questions/60130872
复制相似问题