I am working with Angular 5, in my i am doing as below
ngOnInit() {
this.activatedRoute.parent.params.subscribe(
params => this.branchId = +params['id']
);
this.validateAssignForm();
this.getConfirmReturnValue();
}
getConfirmReturnValue() {
this.subscription1 = this.confirmService.getReturnValue()
.subscribe(
suc => {
console.log('return value::', suc);
if (suc != 0 && suc.hasOwnProperty('returnValue')) {
this.deleteLanguage(suc); }
});
}
but i am not unsubscribing activatedRoute any where in my component as it will unsubscribe by Angular.
In my code i am subscribing BehaviorSubject through shared service. now i am unsubscribing BehaviorSubject in ngOnDestroy() {} function as below
ngOnDestroy() {
this.subscription1.unsubscribe();
}
my question is can i unsubscribe BehaviorSubject like activateRoute (without using ngOnDestroy()) while destroying the current component.