Excuse my typos...
// Subscription collection so we can unsubscribe from them on destroy
private _subscriptions: Subscription[] = [];
// OnInit Hook, triggered each time the component is instantiated
public ngOnInit(): void {
// Add to our subscriptions collection
this._subscriptions.push(
// Subscribe to the ActivatedRoute for paramMap changes
this.route.paramMap.subscribe((paramMap) => {
// Retrieve the view named parameter
const view = paramMap.get('view');
// Check if we have a defined view
if (view) {
// Trigger the view switch
this.currentView(view);
}
})
);
}
// OnDestroy Hook
public ngOnDestroy() {
// Unsubscribe from each Subscription
this._subscriptions.forEach((subscription: Subscription) => {
subscription.unsubscribe() });
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.