When I am trying to subscribe to Subject folder_id, it is not subscribing in the board component when I am passing the id in the files component.
This boardId function is triggered when a button is pressed in the files component. The activateId is the id taken from the snapshot of the url.
boardID(){
this.apiService.folder_id.next(this.activateID.id);
console.log(this.activateID.id);
}
This is the ngOnInit in the boards component which has to subscribe the id that is emitted from the files component. But for some reason when I try to get the id in this component, it does not run this subscribe function.
ngOnInit() {
this.apiService.folder_id.subscribe(
(_id : string) => {
this.id = _id;
console.log(this.id)
}
);
this.page = 0;
console.log('Screen width :', this.scrWidth, 'Screen height', this.scrHeight);
// getting the 2D context of Canvas element
this.canvasElement = this.canvas.nativeElement;
this.ctx = this.canvasElement.getContext('2d');
// setting the Width and Height to the canvas element
this.renderer.setAttribute(this.canvasElement, 'width', this.scrWidth);
this.renderer.setAttribute(this.canvasElement, 'height', this.scrHeight);
// for background
this.backgroundCanvas = this.background.nativeElement;
this.renderer.setAttribute(this.backgroundCanvas, 'width', this.scrWidth);
this.renderer.setAttribute(this.backgroundCanvas, 'height', this.scrHeight);
}
Now this is the service.ts file :-
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Router } from '@angular/router';
import { environment } from 'src/environments/environment';
import { Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class RestService {
xAuthToken = null;
boardId = null;
gerBoardDetails = null;
createFolderResponse = null;
deleteFolderResponse = null;
folder_id = new Subject<string>();
constructor(private http: HttpClient, public router: Router) {}
Can someone please help me on this issue, I am stuck on this for many days now. Thank you.