Below, I have provided my code which utilizes the lazyLoading Module. Please review my code and identify any errors. Currently facing TypeError: Cannot read property 'toLowerCase' of undefined in Angular 7.
Model Class:
export class C_data {
productId:number;
product:string;
code:string;
available:string;
price:number;
rating:number;
productImage:string;
}
allData-page.component.ts:
import {C_data} from '../../shared/model/c_data';
import { AllDataService } from './allData.service';
import { Observable } from 'rxjs';
@Component({
selector: 'all-data',
templateUrl: './alldataPage.component.html'
})
export class AlldataPageComponent implements OnInit {
cdata:Observable<C_data[]>;
constructor(private _allDataService: AllDataService) { }
ngOnInit() {
this._allDataService.getData().subscribe(data => this.cdata);
console.log(this.cdata);
}
}
allData.service.ts:
import { HttpClient } from '@angular/common/http';
import { C_data } from 'app/shared/model/c_data';
import { Observable } from 'rxjs';
@Injectable({providedIn: 'root'})
export class AllDataService {
urls:'../../shared/services/modeldata.json';
constructor(private _httpClient: HttpClient) { }
getData():Observable<C_data[]>{
return this._httpClient.get<C_data[]>(this.urls);
}
}
modeldata.json:
// JSON data here...
alldata.module.ts:
import { CommonModule } from '@angular/common';
import { AllDataRouterModule } from './allData-routing.module';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
CommonModule,
AllDataRouterModule,
HttpClientModule
],
exports: [],
declarations: [AlldataPageComponent]
})
export class AllDataModule { }
allData-routing.module.ts:
import { NgModule } from '@angular/core';
import { AlldataPageComponent } from './allData-page.component';
// Route configuration here...
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: [],
})
export class AllDataRouterModule { }