0

我用材料设计创建了角度库(下面的 package.json)

{
  "name": "angular-lib",
  "version": "0.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "@angular/core": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/material": "^5.0.4",
    "@angular/forms": "^5.2.0",
    "@angular/animations": "^5.2.0",
    "@angular/cdk": "^5.0.4",
    "@angular/platform-browser": "^5.2.0",
    "zone.js": "^0.8.20"
  }
}

当我包含在这个库中时:

import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatCardModule, MatCommonModule } from '@angular/material';

当在这个库中时,所有东西都被导入

@NgModule({
  imports: [
    CommonModule,
    NoopAnimationsModule,
    MatCardModule
  ],
...

我收到错误:

Error: StaticInjectorError(AppModule)[ApplicationRef -> NgZone]: 
  StaticInjectorError(Platform: core)[ApplicationRef -> NgZone]: 
    NullInjectorError: No provider for NgZone!
    at _NullInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js._NullInjector.get (core.js:994)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js.StaticInjector.get (core.js:1102)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.webpackJsonp../node_modules/@angular/core/esm5/core.js.StaticInjector.get (core.js:1102)
    at resolveNgModuleDep (core.js:10836)
    at _createClass (core.js:10881)
    at _createProviderInstance$1 (core.js:10847)
4

1 回答 1

0

我找到了临时解决方案......我的角度库angular-cli 预览应用程序中的node_modules 符号链接工作正常。

ln -s <angular-cli-preview-app>/node_modules <my-angular-library>/node_modules
于 2018-01-15T01:33:21.567 回答