ng-material-extensions icon indicating copy to clipboard operation
ng-material-extensions copied to clipboard

NullInjectorError: StaticInjectorError on "ng build --prod" command to build angular app V8

Open Lubna842 opened this issue 4 years ago • 5 comments

Iam getting the following error while building angular app using --prod tag, otherwise it is working fine. Angular: V8.

NullInjectorError: StaticInjectorError(l)[class{constructor(e,t){this._filterService=e,this._table=t,this.debounceTime=400,this.filterType=yy.ANYWHERE,this.caseSensitive=!1,this.initDebounceSubject()}ngDoCheck(){this._filterService.isChanged(this._oldExampleEntity,this.exampleEntity)&&(this._oldExampleEntity=this._filterService.toPlainJson(this.exampleEntity),this._exampleEntitySubject.next(void 0))}initDebounceSubject(){this._exampleEntitySubject=new ht(null),this._exampleEntitySubject.pipe(Ra(this.debounceTime)).subscribe(e=>{this.updateFilterPredicate()})}updateFilterPredicate(){const e=this.getMatDataSource();e&&(e.filterPredicate=this.getFilterPredicate(),e.filter=this.exampleEntity)}getFilterPredicate(){return this.customPredicate?this.customPredicate:e=>this._filterService.filterPredicate({example:this.exampleEntity,item:e},this.propertyOptions,{filterType:this.filterType,caseSensitive:this.caseSensitive})}getMatDataSource(){return this._table.dataSource}} -> e]: StaticInjectorError(Platform: core)[class{constructor(e,t){this._filterService=e,this._table=t,this.debounceTime=400,this.filterType=yy.ANYWHERE,this.caseSensitive=!1,this.initDebounceSubject()}ngDoCheck(){this._filterService.isChanged(this._oldExampleEntity,this.exampleEntity)&&(this._oldExampleEntity=this._filterService.toPlainJson(this.exampleEntity),this._exampleEntitySubject.next(void 0))}initDebounceSubject(){this._exampleEntitySubject=new ht(null),this._exampleEntitySubject.pipe(Ra(this.debounceTime)).subscribe(e=>{this.updateFilterPredicate()})}updateFilterPredicate(){const e=this.getMatDataSource();e&&(e.filterPredicate=this.getFilterPredicate(),e.filter=this.exampleEntity)}getFilterPredicate(){return this.customPredicate?this.customPredicate:e=>this._filterService.filterPredicate({example:this.exampleEntity,item:e},this.propertyOptions,{filterType:this.filterType,caseSensitive:this.caseSensitive})}getMatDataSource(){return this._table.dataSource}} -> e]: NullInjectorError: No provider for e! at te.get (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:76609) at http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:89989 at e (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:90369) at Xe.get (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:90520) at http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:89989 at e (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:90369) at Xe.get (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:90520) at Xh (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:197296) at Cp.get (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:206054) at qp (http://127.0.0.1:8080/main-es2015.039d00438d69a07a2c65.js:1:209899) Ol @ main-es2015.039d00438d69a07a2c65.js:1 handleError @ main-es2015.039d00438d69a07a2c65.js:1 (anonymous) @ main-es2015.039d00438d69a07a2c65.js:1 invoke @ polyfills-es2015.818dd14191713565ab15.js:1 run @ polyfills-es2015.818dd14191713565ab15.js:1 runOutsideAngular @ main-es2015.039d00438d69a07a2c65.js:1 tick @ main-es2015.039d00438d69a07a2c65.js:1 (anonymous) @ main-es2015.039d00438d69a07a2c65.js:1 invoke @ polyfills-es2015.818dd14191713565ab15.js:1 onInvoke @ main-es2015.039d00438d69a07a2c65.js:1 invoke @ polyfills-es2015.818dd14191713565ab15.js:1 run @ polyfills-es2015.818dd14191713565ab15.js:1 run @ main-es2015.039d00438d69a07a2c65.js:1 next @ main-es2015.039d00438d69a07a2c65.js:1 i @ main-es2015.039d00438d69a07a2c65.js:1 __tryOrUnsub @ main-es2015.039d00438d69a07a2c65.js:1 next @ main-es2015.039d00438d69a07a2c65.js:1 _next @ main-es2015.039d00438d69a07a2c65.js:1 next @ main-es2015.039d00438d69a07a2c65.js:1 next @ main-es2015.039d00438d69a07a2c65.js:1 emit @ main-es2015.039d00438d69a07a2c65.js:1 jg @ main-es2015.039d00438d69a07a2c65.js:1 onHasTask @ main-es2015.039d00438d69a07a2c65.js:1 hasTask @ polyfills-es2015.818dd14191713565ab15.js:1 _updateTaskCount @ polyfills-es2015.818dd14191713565ab15.js:1 _updateTaskCount @ polyfills-es2015.818dd14191713565ab15.js:1 runTask @ polyfills-es2015.818dd14191713565ab15.js:1 m @ polyfills-es2015.818dd14191713565ab15.js:1 invokeTask @ polyfills-es2015.818dd14191713565ab15.js:1 u @ polyfills-es2015.818dd14191713565ab15.js:1 p @ polyfills-es2015.818dd14191713565ab15.js:1

Lubna842 avatar Sep 07 '20 05:09 Lubna842

Could you post your package.json?

HalitTalha avatar Sep 07 '20 05:09 HalitTalha

Well, it is hard to pinpoint what's actually going wrong. It could be the module that's imported with an incorrect path. Maybe you opted-in ivy? If you don't mind please post the relevant ts and html files where you used mat-table-filter?

HalitTalha avatar Sep 07 '20 06:09 HalitTalha

<mat-table matTableFilter [exampleEntity]="filterEntity" [filterType]="filterType" [dataSource]="dataSource" class="mat-elevation-z8" flex layout="row" layout-fill> <ng-container matColumnDef="name"> <mat-header-cell *matHeaderCellDef> <input matInput placeholder="Name" [(ngModel)]="filterEntity.name"> <mat-cell *matCellDef="let element"> {{element.name}} <mat-header-row *matHeaderRowDef="displayedColumns"> <mat-row *matRowDef="let row; columns: displayedColumns;">

Lubna842 avatar Sep 10 '20 13:09 Lubna842

import { Component, OnInit} from '@angular/core'; import { Router } from '@angular/router'; import { myModel } from/model'; import { MatTableDataSource } from '@angular/material'; import { MatTableFilter } from 'mat-table-filter';

export class myComponent implements OnInit {

filterEntity: myModel; filterType: MatTableFilter; displayedColumns: string[] = ['name', 'id']; dataSource:new MatTableDataSource<myModel>(); constructor() { } ngOnInit() { this.dataSource = new MatTableDataSource<myModel>(); this.filterEntity = new myModel(); this.filterType = MatTableFilter.ANYWHERE; }
}

Lubna842 avatar Sep 10 '20 13:09 Lubna842

I faced a similar issue and it was very difficult to debug. This helped me resolve it. I had to add the following dependencies in my app.module.ts file

providers: [MatTableExporterDirective, ServiceLocatorService, DataExtractorService],

https://stackoverflow.com/questions/55927857/nullinjectorerror-no-provider-for-t

zimejin avatar Feb 26 '21 07:02 zimejin