Quiero crear una lista en angular 6 pero obtengo error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'push' of undefined
TypeError: Cannot read property 'push' of undefined
at DatasComponent.<anonymous> (datas.component.ts:23)
este es mi codigo :
export class DatasComponent implements OnInit {
private listUsers: object[];
constructor(private datasService: DatasService) {
console.log(this.datasService);
}
async ngOnInit() {
this.listUsers.push(await this.datasService.getUsers());
}
}