Hey everyone, I've encountered an error that seems to be related to scope and I could use some advice. I'm currently looping through an array and trying to push the results to another array. However, when I attempt to push the results to public myArray:Array from within this.test.forEach, I receive the error "does not exist on type void." Any guidance would be greatly appreciated.
export class componentName implements OnInit {
public myArray:Array<any>;
ngOnInit() {
this.test = diff(this.example1, this.example2);
this.test.forEach(function(part){
let span = document.createElement('span');
span.appendChild(document.createTextNode(part.value));
this.myArray.push(span); // error does not exist on type void
});
}