Reputation: 515
Actually I am trying to navigate from main Component to login Component after two database request(post and put). Its not working.
constructor(private service:Service, private router:Router){}
select(solution:string, size:string) {
let obj1 = {};
let obj2 = {}
this.service
.newObj(obj1)
.subscribe(
(data) => {this.service.status(obj2, data._id).subscribe((data) =>**this.router.navigate(['/login'])**);
console.log('data.id', data._id)},
error => console.log('Could not post data.'));
}
Upvotes: 1
Views: 9324
Reputation: 6839
I think that you intended to navigate through a URL segment, 'login', then you should use navigateByUrl
instead:
this.router.navigateByUrl('/login')
Upvotes: 4