Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change component at the end of function Angular

How can I change to the restricted-page component after completion of the login() function which is a redirect to microsoft log in?

public-page.component.ts

  login() {
  this.msalService.loginRedirect();
  //switch to restricted-page here.
  }

app-routing.module.ts:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    const routes: Routes = [{
  path: 'public-page', component: PublicPageComponent
}, {
  path: 'restricted-page', component: RestrictedPageComponent, canActivate: [MaslGuard]
}, {
  path: '', redirectTo:'public-page', pathMatch:'full',
}];

>Solution :

in login function you have to add:

if (login successfull){
this.router.navigate(['/restricted-page'])
 }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading