I'm initializing an array and trying to push elements into the array. But I get this error saying Cannot read property 'list' of undefined.
list: Array<any> = [];
this.data.forEach(function(element) {
this.list = [];
});
this.data.forEach(function(element) {
this.list.push({
'name' : this.url
})
});
Even though I'm initializing the array, it is saying as undefined