As I work on setting up a simple error notifications component and debug in Visual Studio, an issue arises within the subscribe function where 'this' is undefined.
public notifications: NotificationMessage[];
constructor(notificationService: NotificationService) {
this.notifications = []; //'this' is defined here
notificationService.rxEmitter.subscribe((notificationMessages: any) => {
this.notifications = notificationMessages; //'this' is undefined here
});
}
Update : Here is a screenshot showing 'this' being undefined at a breakpoint in VS. Interestingly, '_this', despite existing at runtime, cannot be referenced as TypeScript throws a reference not found error during compilation.