I'm facing an issue in my code where I have buttons that should trigger pop-ups displaying details as a list when clicked. However, every time I click the buttons, I encounter the error mentioned below. It seems like I am unable to access the desired property. Can you help me identify what might be wrong with my code and suggest a way to fix it?
TS Code:
@Component({
selector: 'warehouse-detail-dialog',
templateUrl: './warehouse-detail-dialog.component.html',
styleUrls: ['./warehouse-detail-dialog.component.scss']
})
export class WarehouseDetailDialogComponent implements OnInit {
cell: ICell;
userRights: IActionRoleMap;
displayedColumns: string[] = [
'EntryPackageBarcode',
'StockIntegrationCode',
'ProductName',
'Balance',
];
dataSource: MatTableDataSource<IStockPackageTransaction>;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild(MatSort, { static: true }) sort: MatSort;
constructor(
private _terminalService: TerminalService,
private _router: Router
) {
_terminalService.onCellDetailChanged.subscribe((response: ICell) => {
this.cell = response;
this.dataSource = new MatTableDataSource(response.StockPackageTransactions);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
});
}
TS for Service:
cellDetail: ICell;
onCellDetailChanged: BehaviorSubject<any> = new BehaviorSubject([]);
getCellDetailById(id: string) {
return new Promise((resolve, reject) => {
this._http
.get("Production/GetCellDetailById/" + id)
.subscribe((response: ICell) => {
this.cellDetail = response;
this.onCellDetailChanged.next(this.cellDetail);
resolve(this.cellDetail);
}, reject);
});
}
Error:
WarehouseDetailDialogComponent_Host.ngfactory.js? [sm]:1 ERROR NullInjectorError: StaticInjectorError(AppModule)[WarehouseDetailDialogComponent -> TerminalService]:
StaticInjectorError(Platform: core)[WarehouseDetailDialogComponent -> TerminalService]:
NullInjectorError: No provider for TerminalService!
at NullInjector.get (core.js:778)
at resolveToken (core.js:2564)
at tryResolveToken (core.js:2490)
at StaticInjector.get (core.js:2353)
at resolveToken (core.js:2564)
at tryResolveToken (core.js:2490)
at StaticInjector.get (core.js:2353)
at resolveNgModuleDep (core.js:26403)
at NgModuleRef_.get (core.js:27491)
at resolveNgModuleDep (core.js:26403)