data: function () {
return {
selectedScope:'',
}
},
methods: {
displayScope: function(newScope) {
console.log(this.selectedScope)
var resultArray = []
this.tableData.forEach(function (data) {
if (data.iog === this.selectedScope) { // This is where the error
resultArray.push(data)
}
});
}
}
I can't seem to figure out why i m getting:
Cannot read property 'selectedScope' of undefined
inside the forEach
.
Why?