0
votes

I have two applications. From one applications we are coming to second applications. from the first application

http://localhost:8080/myfirst-portal/?account_number=RDQsssyMDE=&firstname=UssssGhpbA==&lastname=RGFsssuY2U=&role=csssG9ydGFsZmllbGR1c2Vy

while coming from first application to second application it will send some data to second application.

second application http://localhost:8080/myapp/#/login

Based on URL prams from the first application we have to redirect to specific component.

routes in angular app

{ path: '', pathMatch: 'full', redirectTo: '/login' }, { path: '**', pathMatch: 'full', redirectTo: '/login' },

what is best way to achieve this?

2
First application is not a angular application - Bemagoni Chandrashekar

2 Answers

1
votes

subscribe to route events and then

ngOnInit() {
    this.sub = this.route.params.subscribe(params => {
       this.id = +params['id']; // (+) converts string 'id' to a number

       // apply you condition here{
         this.router.navigateByUrl(['show_alunos']);
        }
    });
  }

and if you want to read detailed explanation you may read this topic using click here having good topics

also, configure you route file

RouterModule.forRoot([
  { path: 'login', component: LoginComponent },
  { path: 'nomination', component: HomeComponent }
])

try with NavigationEnd

previousUrl: string;
constructor(router: Router) {
  router.events
  .filter(event => event instanceof NavigationEnd)
  .subscribe(e => {
    console.log('prev:', this.previousUrl);
    this.previousUrl = e.url;
  });
}
0
votes

If you have your routes set in the second application, Angular Router will do the job itself.

If in your second app you have configuration similar to this for example:

RouterModule.forRoot([
  { path: 'login', component: LoginComponent },
])

And you redirect the user with the the link like this: http://secondapplink.com/login

Then, Angular router will find and render Login component itself.

Of course, in production, where the application is deployed, you must set up the URL rewriting so you don't end up with errors. In development mode you should not worry about this.