I am encountering an issue where an observable is not being invoked from the HTML page. The method works perfectly fine when triggered by angular and displays the desired output. However, when attempting to invoke it through a button, it does not work.
Service
deltasHistory = this.socket.fromEvent<any[]>('deltasHistory');
Component
constructor(private codeeditorservice: CodeeditorService){}
ngOnInit() {
this.deltaHistory$.subscribe(delta => {
console.log(delta[30]); // Works perfectly
})
}
Currently, the invoke()
function is triggered by
<button (click)="invoke()">Button</button>
but it does not display anything.
Button inside the Component's HTML
invoke(){
console.log("invoking") // displays
this.deltaHistory$.subscribe(delta => {
console.log(delta[30]);
}) //nothing
}
What can be done to address this scope issue?