I am getting an error of
Argument of type 'ActivatedRoute' is not assignable to parameter of type 'ActivatedRoute'.
Types of property 'url' are incompatible. Type 'Observable' is not assignable to type 'Observable'. Two different types with this name exist, but they are unrelated. Property 'source' is protected but type 'Observable' is not a class derived from 'Observable'.
my typescript is as follows...I am getting error in navigateToList()
import { Component, ViewChild, OnInit } from '@angular/core'
import { Router, ActivatedRoute } from '@angular/router'
import { getParentRoute } from 'PwcLib/common'
import { ValidatorsService } from 'PwcLib/core-services'
import { ValidationForm } from 'PwcLib/validation'
import { CanDeactivateComponent } from 'PwcLib/routing'
import { UsersSyncService } from '../users.service'
import { User } from '../user'
@Component({
// define a templateUrl for component
templateUrl: 'user-details.component.html'
})
export class UserDetailsComponent implements OnInit, CanDeactivateComponent
{
user: User;
userId: number;
@ViewChild(ValidationForm) form: ValidationForm;
constructor(
private usersSyncService: UsersSyncService,
private router: Router,
private activatedRoute: ActivatedRoute,
private validators: ValidatorsService
) {
}
ngOnInit() {
//ngOnInit is not executed on parameters change so supscribe to params
this.activatedRoute.params.forEach((params) => {
let userIdParam = parseInt(params['userId']);
this.userId = isNaN(userIdParam) ? 0 : userIdParam;
if (this.userId == 0) {
this.user = <User>{};
} else {
this.user = this.usersSyncService.getUser(this.userId);
if (!this.user) {
this.navigateToList();
}
}
});
}
canDeactivate() {
if (!this.form) return true;
return this.form.allowNavigation();
}
private navigateToList() {
// ../ navigates one level up in route but route can have few parts like /details/:id so getParentRoute utility is used to get parent route
this.router.navigate(['./'], { relativeTo: getParentRoute(this.activatedRoute) });
}
}