我在安装了星云库的情况下,新创建了“角计划”。我想创建3页。(登录,注册,和主页)。我已经分别用内置的NbLoginComponent和NbRegisterComponent创建了登录和注册页面。现在,我想在用户成功登录后,一旦单击NbLoginComponent的登录按钮(基本上我希望使用这个login()导航到HomePage),就会导航到NbLoginComponent。那么,我需要在哪里实现这样的功能呢?
现在,我无法做任何类似的事情,它停留在与NbLoginComponent相同的页面中。
同样,对于NbRegisterComponent,如果我使用<nb-register></nb-register>,一旦用户成功注册,我想导航到登录页面-->成功登录后的->主页。
那么,我需要在哪里实现这样的功能与星云库?
我已经有了相关的网页,如登录,注册,注销等(最新的角7和最新的星云库)。
仅限NbLoginComponent和NbRegisterComponent代码
期望:通过使用NbLoginComponent中的login(),需要在成功的login.And之后导航到主页,使用NbRegisterComponent的寄存器()需要在成功注册后导航到loginPage。
实际情况:在上述两种情况下,它都停留在相同的页面中(意思是在成功登录后单击登录按钮,它就停留在相同的登录页面中,同样用于注册)。
发布于 2019-05-17 13:40:38
如果您使用的是NbLoginComponent.js,并且在装饰函数中设计了页面,那么我建议您在login()方法中添加以下代码,如下所示
NbLoginComponent.prototype.login = function () {
var _this = this;
this.errors = [];
this.messages = [];
this.submitted = true;
this.service.authenticate(this.strategy, this.user).subscribe(function (result) {
_this.submitted = false;
if (result.isSuccess()) {
_this.messages = result.getMessages();
_this.router.navigateByUrl("/homepageurl");
}
else {
_this.errors = result.getErrors();
}
_this.cd.detectChanges();
});
};您将被重定向到主页。类似地,您可以添加
_this.router.navigateByUrl("/login");
在RegisterComponent中重定向到登录页面。
https://stackoverflow.com/questions/55393617
复制相似问题