I am currently writing my first Angular 2 Application. I have an OverviewComponent which has the following simple template:
Is possible to detect any change in the parameters received, in my case I load the information using a Resolve so I don't need the parameter (only detect if it change). This is my final solution:
public product: Product;
private parametersObservable: any;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.parametersObservable = this.route.params.subscribe(params => {
//"product" is obtained from 'ProductResolver'
this.product = this.route.snapshot.data['product'];
});
}
//Don't forget to unsubscribe from the Observable
ngOnDestroy() {
if(this.parametersObservable != null) {
this.parametersObservable.unsubscribe();
}
}