【发布时间】:2019-01-25 08:19:48
【问题描述】:
我试图将我的页面从登录重定向到另一个页面。我遵循此代码。
我的登录组件ts文件:
import { Router } from '@angular/router';
constructor(private router: Router) {
}
funLogin(mobilenumber){
this.router.navigateByUrl('registration');
}
在我的 html 中,我在提交 btn 中调用此函数,
<button class="common-btn btn" (click)="funLogin(mobileNo.value)">Submit</button>
In my app.login.routing file,
export const loginRouting: Routes = [
{
path: '', component: DashboardRootComponent, canActivateChild: [],
children: [
{ path: '', component: DashboardComponent, pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'registration', component: RegistrationComponent },
]
}
]
我已尝试使用“this.router.navigate”和引用的链接。但它没有用。谁能告诉我我哪里出错了,或者如果你能给我一个工作样本会更好。
【问题讨论】:
-
您在尝试上述代码时是否遇到任何错误?
标签: html angular url routing angular6