I have a method "authenticate" that lets me login. I don't really know if it works because I use dummy login, just to test the routing and returned date. The problem with this method is that on successful login I should be redirected to the Actuals page, which at this moment doesnt work.
authenticate(username, password) {
var creds = JSON.stringify({ UserName: username.value, UserPassword: password.value, SetDebug: true});
var headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('http://demo/aariworx5/api/login/login', creds ,{headers: headers})
.subscribe(
res => {
this.data = res.json();
this.router.parent.navigate('/Actuals');
},
error => console.log(error)
);
}
}
The error I get is the following: TypeError: Cannot read property 'parent' of undefined. I can guess from what I read that this page is not the parent of the Actuals page. I have tried the suggestion in another post: this.router.parent.navigate(['/Actuals']); That was in the post: Angular 2 - How to navigate to another route using this.router.parent.navigate('/about') This does not work in my case, don't know why...