0

I've created angular library with material design (package.json below)

{
  "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"
  }
}

When I include in this library:

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

and when inside this library everything is imported

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

I am getting error:

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)
Dariusz Filipiak
  • 2,858
  • 5
  • 28
  • 39
  • The problematic here is import `BrowserAnimationsModule` or `NoopAnimationsModule` ... Without it some of the angular material components works (like mat-card) but other doesn't.. And I see similar errors with StaticInjectorError.. – Dariusz Filipiak Jan 15 '18 at 00:41

1 Answers1

0

I found temporary solution... My angular library with node_modules symlink from angular-cli preview app works fine.

ln -s <angular-cli-preview-app>/node_modules <my-angular-library>/node_modules
Dariusz Filipiak
  • 2,858
  • 5
  • 28
  • 39
  • You should not import these modules from the library. They should be imported by the app that uses it. – n00dl3 Jun 19 '18 at 11:11
  • Probably yes... but now I've got one node_modules folder in my workspace for each angular app or library and everything works fine. This problem occur while I was creating example app of my isomorphic library https://github.com/darekf77/morphi – Dariusz Filipiak Jun 21 '18 at 11:32