Angular project忘记密码发送电子邮件链接在Chrome浏览器中不工作(仅第一次。第二次按预期工作)
我正在开发一个angular6应用程序,并部署了一个域名“www.mydomain.com/” 所有的路由工作正常,如“www.mydomain.com/dashboard”、“www.mydomain.com/products”等 问题是我们有一个更改密码来链接它,就像“www.mydomain.com/mga/sps/authscrun:ibm:security:authentication/changePassword”。(链接正在向我们的邮件id发送OTP邮件,该id用于登录应用程序并等待更新OTP) 我使用链接重定向更改密码。但由于路由相同的域,它将不会重定向到主页“www.mydomain.com/” 更新 该问题仅在首次使用chrome浏览器时出现。当我第一次登录时单击“更改密码”按钮,链接被触发,但几秒钟后重定向到主页 第二次单击同一按钮时,链接将重定向到正确的页面(更改密码URL页面) 我如何解决这个问题?请帮帮我 代码如下: my-profile.component.htmlAngular project忘记密码发送电子邮件链接在Chrome浏览器中不工作(仅第一次。第二次按预期工作),angular,routes,angular6,Angular,Routes,Angular6,我正在开发一个angular6应用程序,并部署了一个域名“www.mydomain.com/” 所有的路由工作正常,如“www.mydomain.com/dashboard”、“www.mydomain.com/products”等 问题是我们有一个更改密码来链接它,就像“www.mydomain.com/mga/sps/authscrun:ibm:security:authentication/changePassword”。(链接正在向我们的邮件id发送OTP邮件,该id用于登录应用程序并等
更改密码
my-profile.component.ts
changePassword(){
window.location.href='www.mydomain.com/mga/sps/authscrun:ibm:security:authentication/changePassword';
}
您可以将changePassword()
方法更改为:
<a (click)="changePassword($event)">Change Password</a>
changePassword(event) {
window.location.href = 'www.mydomain.com/mga/sps/authsvcurn:ibm:security:authentication/changePassword';
event.preventDefault();
}
更新
可以帮助您调试的其他要点: 1-启用路由跟踪(在
app routing.module.ts
中):
导入:[
RouterModule.forRoot(
路线,
{enableTracing:true}/您可以将changePassword()
方法更改为:
<a (click)="changePassword($event)">Change Password</a>
changePassword(event) {
window.location.href = 'www.mydomain.com/mga/sps/authsvcurn:ibm:security:authentication/changePassword';
event.preventDefault();
}
更新
可以帮助您调试的其他要点:
1-启用路由跟踪(在app routing.module.ts
中):
导入:[
RouterModule.forRoot(
路线,
{enableTracing:true}/您已经尝试过角度路由器了吗
import { Router } from '@angular/router';
constructor(
private router: Router
) { }
changePassword() {
this.router.navigate(['/myURL', { myParamName: myParamValue }]);
}
在目标组件中:
import { ActivatedRoute, ParamMap } from '@angular/router';
constructor(
private route: ActivatedRoute
) { }
public ngOnInit() {
this.route.paramMap
.subscribe((params: ParamMap) => {
const myParamValue = params.get('myParamName');
if (myParamValue) {
}
});
}
你已经试过角度路由器了吗
import { Router } from '@angular/router';
constructor(
private router: Router
) { }
changePassword() {
this.router.navigate(['/myURL', { myParamName: myParamValue }]);
}
在目标组件中:
import { ActivatedRoute, ParamMap } from '@angular/router';
constructor(
private route: ActivatedRoute
) { }
public ngOnInit() {
this.route.paramMap
.subscribe((params: ParamMap) => {
const myParamValue = params.get('myParamName');
if (myParamValue) {
}
});
}
您还可以显示路由文件中的路径吗?尤其是应该与changePassword组件匹配的路径?Angular没有任何用于“更改密码”的组件。该链接与其他团队提供的某些外部URL不同。打开网络调试器,检查是否存在任何重定向或错误。您的mga/sps/…
页面是否为角度路由?您是否也可以在路由文件中显示路径?尤其是应与changePassword组件匹配的路径?角度没有任何组件r“更改密码”。该链接与其他团队提供的某些外部URL不同。打开网络调试器,检查是否存在任何重定向或错误。您的mga/sps/…
页面是否有角度路由?它不工作。首次登录应用程序后,单击“更改密码”按钮它重定向到主页,但再次单击它重定向到正确URL的按钮(忘记密码链接)我更新了我的答案。如果新方法在你这方面不起作用,我建议提供路由路径和其他相关代码部分,或者创建一个stackBlitz演示。我尝试过,但由于某些原因无法创建stackBlitz。我更新了我的答案,只给出了一个提示,需要更多信息。它不起作用。在在应用程序中,第一次单击“更改密码”按钮,它将重定向到主页,但再次单击按钮,它将重定向到正确的URL(忘记密码链接)我更新了我的答案。如果新方法对你方不起作用,我建议提供路由路径和涉及的代码的其他部分,或者创建一个stackBlitz演示。我尝试过,但由于某些原因无法创建stackBlitz。我用一个提示更新了我的答案,并且需要更多信息。