angular - Angular In-App-Navigation with routerlink doesn't work as planned
问题描述
I have created a <nav mat-tab-nav-bar like this:
<nav mat-tab-nav-bar>
<a mat-tab-link routerLink="">Product Shop</a>
<a mat-tab-link routerLink="Login">User Login</a>
<a mat-tab-link routerLink="Registration">User Registration</a>
</nav>
I can switch between the Tabs and the router link works!
In the registration tab I created a button which should navigate to the login, but it doesn't work
<button routerLink="Login" mat-button color="primary" type="submit">
Log in
</button>
When I click on it I stay in the registration route.
The button isn't the problem because when I add the same button in Product shop (Home-Tab --> routerlink= "") it goes to the login tab. But if I'm in another tab than home the button doesn't work anymore. so I can go from "" to "registration" or "login" but cant go from "registration" to "login".
解决方案
I think your routerLink should refer to "Login". Currently you have set it to "Registration" which would, as you mention, redirect you to the same page.
So like this:
<button routerLink="Login" mat-button color="primary" type="submit">
register
</button>
推荐阅读
- javascript - s% 如何引用 Helmet 组件内的 title 属性?
- c++ - 如何将多个参数传递给 std::thread?
- opencart-3 - 添加链接到管理菜单 opencart 版本 3.0.2.0
- android - 当我单击 android 日历列表视图中的重置按钮时如何清除选定的日期范围
- android - 无法在android中以编程方式通过intent打开PDF文件
- model-view-controller - 如何在 .net 核心中访问数据库上下文表单视图
- google-bigquery - 在 Bigquery 中计算大量向量之间的成对余弦相似度
- ios - 如何在 xamarin.ios 中控制来自 Dependecy-service 的背景音频
- excel - VBA 单击并键入 XMLHTTP
- c# - 从 IIS 打印无法在作为本地 asp.net 连接的共享打印机上工作