Reputation: 967
I'm super new at Angular and NativeScript and can't really figure out how to do the whole routing thing. Currently, I'm getting an error where it's saying
Error: Cannot match any routes. URL Segment: 'signIn'
Here's the .html, home.component.html
, where my button is:
<Button class="btn btn-primary btn-rounded-sm" style="width: 90%; height: 7%; padding: 0px; margin: 5px; background-color: black; color: white; vertical-align: bottom;" text="Sign pIn" (tap)=onSignIn()></Button>
Here's the component, home.component.ts
, where the function is:
onSignIn(): void {
this.router.navigate(['signIn']);
}
and then, here's my signIn.component.ts
:
import { Component, OnInit } from "@angular/core";
@Component({
selector: "SignIn",
moduleId: module.id,
templateUrl: "./signIn.component.html",
styleUrls: ['./signIn.component.css']
})
export class SignInComponent implements OnInit { }
Also, here's where my route is configured in my app-routing.module.ts
:
{ path: "signIn", redirectTo: "/signIn", pathMatch: "full" }
Any help would be greatly appreciated. Thanks!
Upvotes: 1
Views: 1059
Reputation: 29705
Instead of redirect
, load the component
over there. So you have to replace redirectTo: "/signIn"
with component: SignInComponent
.
const routes: Routes = [
{ path: "signIn", component: SignInComponent, pathMatch: "full" }
];
See this small DEMO
Note : And also you should not be redirecting to the same route, it would become recursive. At the end, angular will not find any component to load which might lead to
cannot-match-any-routes error
Upvotes: 2