ng-alain懒加载模块 未添加导致NZ模块未识别Can't bind to 'nzExtra' since it isn't a known property of 'nz-card

ng-alain懒加载模块 未添加导致NZ模块未识别

Can't bind to 'nzExtra' since it isn't a known property of 'nz-card'.
1. If 'nz-card' is an Angular component and it has 'nzExtra' input, then verify that it is part of this module.
2. If 'nz-card' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("

这个问题出现在我运用ng-alain建立工作区的子路由引用时,组件正常引入路由后可以使用angular代码 CSS HTML和JS 但是无法引用ng-zorro和ng-alain的组件 引入后浏览器都会报这个错。

首先上我的目录结构
ng-alain懒加载模块 未添加导致NZ模块未识别Can't bind to 'nzExtra' since it isn't a known property of 'nz-card_第1张图片
由于我建立模块使用的是 ng g m XXX 的angular cil命令生成的子模块组件是这样的

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommentRoutingModule } from './comment-routing.module';
import { Test1Component } from './test1/test1.component';
import { Test2Component } from './test2/test2.component';

@NgModule({
  imports: [
    CommonModule,
    CommentRoutingModule
  ],
  declarations: [Test1Component, Test2Component],
  entryComponents: [
    Test1Component, Test2Component
  ]
})
export class CommentModule { }

这样导致了没有默认生成懒加载模块 会无法识别主模块app-modules的引入的ng-zorro文件

但是当我用 ng g ng-alain:module sys 类似的alain cil命令生成相同的目录模块缺成功使用了

然后我对比了一下2个文件的差别

import { NgModule } from '@angular/core';
import { SharedModule } from '@shared';
import { DuesRoutingModule } from './dues-routing.module';
import { DuesTest1Component } from './dues/test1/test1.component';
import { DuesTest2Component } from './dues/test2/test2.component';
import { Test3Component } from './dues/test3/test3.component';

const COMPONENTS = [
  DuesTest1Component,
  DuesTest2Component];
const COMPONENTS_NOROUNT = [];

@NgModule({
  imports: [
    SharedModule,
    DuesRoutingModule
  ],
  declarations: [
    ...COMPONENTS,
    ...COMPONENTS_NOROUNT,
    Test3Component
  ],
  entryComponents: COMPONENTS_NOROUNT
})
export class DuesModule { }

对比差别 就在于

    SharedModule,

这个地方出现的懒加载模块,在ng-alain 设立的子模块路由节点节目所有的都必须使用
SharedModule 引入 才能使用全局引入的如ng-zorro的组件。

你可能感兴趣的:(angular,ng-alain)