Currently, I am learning Angular 2 + PrimeNG and going through a quick start project available at the following link: https://github.com/primefaces/primeng-quickstart
The project is a CRUD application and it functions flawlessly. The data is neatly displayed in a table on my browser. It's impressive!
However, as I attempt to make some modifications to the code, everything seems to work fine except for my own code glitch.
export class AppComponent {
displayDialog: boolean;
car: Car = new PrimeCar();
selectedCar: Car;
newCar: boolean;
cars: Car[];
constructor(private carService: CarService) { }
ngOnInit() {
this.carService.getCarsMedium().then(cars => this.cars = cars);
//MY CODE LIES HERE:
console.log(this.cars);
for (let entry of this.cars) {
console.log(entry);
}
}
The initial console.log
returns an undefined
message while the subsequent for
loop disrupts the application flow.
Essentially, I am trying to mirror the data being shown in the browser onto the console. Any assistance would be greatly appreciated!
Thank you! =)