[AngularJS] Store the entry URL and redirect to entry URLs after logged in

Source: Internet
Author: User

For example when a outside application need to visit your app address:

Https://www.example.com/#/lobby/abc

But before enter '/LOBBY/ABC ', user need to login, so the application would redirect user to

Https://www.example.com/#/login

Now what are you want are after the user logged in, can redirect them to

Https://www.example.com/#/lobby/abc

Instead of other pages like:

Https://www.example.com/#/lobby

So-solve the problem, we need to do, and things

1. Store The entry URL

2. After logged in, redirect user to entry URL

1. Store The entry ur:

Angular.module (' app ')     // when the can get pull URL by using $location. Absurl ()    //  Because run block only run once for the module and app module are our main application module, so this should onl Y store our entry URL    /  to reuse the Entryurl later, we store it in Loginservice    . Run (($l Ocation, loginservice) = Loginservice.entryurl = $location. Absurl ())

2. After logged in, then we can redirect user to the entry URL by doing:

$location. URL (loginservice.entryurl)

[AngularJS] Store the entry URL and redirect to entry URLs after logged in

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.