core.js:4442 ERROR RangeError: Maximum call stack size exceeded
at SafeSubscriber.__tryOrUnsub (Subscriber.ts:271)
at SafeSubscriber.next (Subscriber.ts:207)
at Subscriber._next (Subscriber.ts:139)
at Subscriber.next (Subscriber.ts:99)
at BehaviorSubject.Subject.next (Subject.ts:70)
at BehaviorSubject.next (BehaviorSubject.ts:43)
at SharedService.push.r2F1.SharedService.setTitleInfo (shared.service.ts:92)
at AppComponent.push.Sy1n.AppComponent.nameChangeFunction (app.component.ts:190)
at app.component.ts:167
at SafeSubscriber.schedulerFn [as _next] (core.js:24931)
The above code snippet highlights an error that I am encountering in my application.
This error is being triggered within the app.component.ts file, as shown in the following code:
I seem to be facing some confusion regarding the cause of this error appearing in the console.
ngAfterViewChecked() {
this.titleSubscription = this.sharedService.getTitleValue()
.subscribe(item => {
this.customNameData = false;
if (item === 'View My Request' || item === 'Request Management') {
this.nameChangeFunction(item)
}
const substring = 'customNameData';
if (item.includes(substring)) {
const length = item.length;
const res = item.substr(14, length);
this.title = res;
this.customNameData = true;
} else {
this.title = item
}
});
this.routerLinkSubscription = this.sharedService.getRouterLinkValue()
.subscribe(item => {
this.routerLink = item
});
this.cdr.detectChanges();
}
nameChangeFunction(item) {
if (item === 'View My Request' || item === 'Request Management') {
this.sharedService.setTitleInfo({
data: item
});
}
}
It seems like there might be an issue with the shared.service.ts file. Despite attempting to clear the stack, I have not found a successful solution yet. Any guidance on resolving this would be greatly appreciated.
setTitleInfo(name: any) {
this.setTitle.next(null);
this.setTitle.next(name);
}
If anyone can provide insight into what may be causing this error and how it can be resolved, I would be grateful for the assistance.