How can I decode part of the query string of a URL in my AngularJS application?

Alan2

I have this code:

var search = $location.search();
    if (angular.isDefined(search.load) && search.load != null) {
        if (search.load = "confirmEmail")
            authService.confirmEmailUserId = search.userId;
            authService.confirmEmailCode = search.code;
            $state.transitionTo("auth.content", {
                content: search.load
            });
    }

It's in the app.run and it looks at the URL used to open the app.

But search.code was encoded with the C#

 var callbackUrl  = "http://localhost:2757/index.html" +
                    "?load=email" +
                    "&userId=" + user.Id +
                    "&code=" + HttpUtility.UrlEncode(code);

How can I get back the original value of code before it was passed to UrlEncode?

Andrei V

You could use the decodeURIComponent() JavaScript function. This function takes as parameter an URL encoded string and returns its unencoded form.

In your case, you could either decode the entire URL

var search = decodeURIComponent($location.search());

or just the code part

authService.confirmEmailCode = decodeURIComponent(search.code);

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I rewrite my controller URL?

분류에서Dev

In SQL Server, how can I compare a part of a string?

분류에서Dev

How can I find why system can not run my application?

분류에서Dev

How can I know if an application reads my hardware fingerprint?

분류에서Dev

How can I open website in my android application?

분류에서Dev

Android - How can i create a "black list" for the files of my application

분류에서Dev

How can I optimize my EF Code First query?

분류에서Dev

How can i get my query execution time in logging

분류에서Dev

How can I ensure what I'm about to str_ireplace isn't a part of a url?

분류에서Dev

How can I declare a const string in my Stimulus JS controller?

분류에서Dev

How can I strip out all HTML from my string

분류에서Dev

How can I convert that json string to my class

분류에서Dev

My springboot application creates a pdf file on openshift how do I get url for that file

분류에서Dev

How can I encode and decode an Array of Numbers in Objective-C?

분류에서Dev

How can I decode special characters in a JavaScript variable?

분류에서Dev

How can I add code into my directive with transclude and pass in a parameter in AngularJS?

분류에서Dev

why there is difference between psql -version output and the psql version connected to my application? how can I resolve this

분류에서Dev

How can I integrate FusionChart in my SPA application developed using Durandal and Knockout?

분류에서Dev

How can I tell if my Cordova application is running on a simulator or real device?

분류에서Dev

How can I setup a variable in the application_controller and have is show in my footer?

분류에서Dev

How can I correct error in my WPF Application when using Azure as a media resource (CDN)?

분류에서Dev

In my SQL query, how can I have a column with values queried from another table?

분류에서Dev

How can I make my query set order by descending in django based on auto increment id field

분류에서Dev

Can I get only the part of the string that matches with Grep

분류에서Dev

How can I redirect my homepage to a random url through firebase hosting?

분류에서Dev

How can I send inputs to a URL (someone else's server) and get the output back for use in my PHP?

분류에서Dev

AngularJS: Where can I see $httpBackend responses in my browser directly?

분류에서Dev

Can I transfer private data of my Android application to inspect?

분류에서Dev

I can't show AdMob banner in my application

Related 관련 기사

  1. 1

    How can I rewrite my controller URL?

  2. 2

    In SQL Server, how can I compare a part of a string?

  3. 3

    How can I find why system can not run my application?

  4. 4

    How can I know if an application reads my hardware fingerprint?

  5. 5

    How can I open website in my android application?

  6. 6

    Android - How can i create a "black list" for the files of my application

  7. 7

    How can I optimize my EF Code First query?

  8. 8

    How can i get my query execution time in logging

  9. 9

    How can I ensure what I'm about to str_ireplace isn't a part of a url?

  10. 10

    How can I declare a const string in my Stimulus JS controller?

  11. 11

    How can I strip out all HTML from my string

  12. 12

    How can I convert that json string to my class

  13. 13

    My springboot application creates a pdf file on openshift how do I get url for that file

  14. 14

    How can I encode and decode an Array of Numbers in Objective-C?

  15. 15

    How can I decode special characters in a JavaScript variable?

  16. 16

    How can I add code into my directive with transclude and pass in a parameter in AngularJS?

  17. 17

    why there is difference between psql -version output and the psql version connected to my application? how can I resolve this

  18. 18

    How can I integrate FusionChart in my SPA application developed using Durandal and Knockout?

  19. 19

    How can I tell if my Cordova application is running on a simulator or real device?

  20. 20

    How can I setup a variable in the application_controller and have is show in my footer?

  21. 21

    How can I correct error in my WPF Application when using Azure as a media resource (CDN)?

  22. 22

    In my SQL query, how can I have a column with values queried from another table?

  23. 23

    How can I make my query set order by descending in django based on auto increment id field

  24. 24

    Can I get only the part of the string that matches with Grep

  25. 25

    How can I redirect my homepage to a random url through firebase hosting?

  26. 26

    How can I send inputs to a URL (someone else's server) and get the output back for use in my PHP?

  27. 27

    AngularJS: Where can I see $httpBackend responses in my browser directly?

  28. 28

    Can I transfer private data of my Android application to inspect?

  29. 29

    I can't show AdMob banner in my application

뜨겁다태그

보관