AngularJS ngRoute - specify data for target page, with data not appearing in URLHow does data binding work in AngularJS?AngularJS passing data to $http.get requestAngularJS : Initialize service with asynchronous dataAngularJS: How to clear query parameters in the URL?Build query string from parameters objectangularjs not detecting the redirect urlAngularJS ui router passing data between states without URLAngularJS Spring MVC Redirection with data bindingangularjs ngroute not workingngRoute Params url on refresh Not working

Can an open source licence be revoked if it violates employer's IP?

How can religions without a hell discourage evil-doing?

Someone who is granted access to information but not expected to read it

Leveling up and Getting Items!

Does anyone recognize these rockets, and their location?

Can artificial satellite positions affect tides?

How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?

Threading data on TimeSeries

100-doors puzzle

How to search for Android apps without ads?

Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?

Converting 3x7 to a 1x7. Is it possible with only existing parts?

New Site Design!

How many times to repeat an event with known probability before it has occurred a number of times

I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?

Does WiFi affect the quality of images downloaded from the internet?

The title "Mord mit Aussicht" explained

Leveraging cash for buying car

Creating polygon with exact measurements in QGIS 3

The last tree in the Universe

Cremated People Pottery

How to know whether to write accidentals as sharps or flats?

Fastest path on a snakes and ladders board

How can I improve readability and length of a method with many if statements?



AngularJS ngRoute - specify data for target page, with data not appearing in URL


How does data binding work in AngularJS?AngularJS passing data to $http.get requestAngularJS : Initialize service with asynchronous dataAngularJS: How to clear query parameters in the URL?Build query string from parameters objectangularjs not detecting the redirect urlAngularJS ui router passing data between states without URLAngularJS Spring MVC Redirection with data bindingangularjs ngroute not workingngRoute Params url on refresh Not working






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm using AngularJS and I would like to redirect a user when he clicks a button on /page1 to /page2. I currently use AngularJS routing for this using ngRoute which works all fine. However, in addition to the redirection, I would also like to pass some data from page1 to page2 to pre-populate some of the HTML on page2. I know that in order to pass such data, I can either specify it in the path parameter,e.g.



/page2/<param1>/<param2>


or as a query string parameter, e.g.



 /page2?<key1>=<value1>&<key2=value2>


In both ways, I can retrieve the query string or path params in /page2 using $route.current.params



However, I do not want to do either of the above as I do not want to expose my data on the URL to the user. Is there a way in AngularJS that the parameters can be passed to /page2, such that they are "hidden" from the URL?



Thanks










share|improve this question
























  • You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

    – georgeawg
    Mar 25 at 4:43











  • thanks, using a service worked! if you can add an answer I can accept it.

    – Shrikanth Rajgopalan
    Mar 25 at 6:28

















0















I'm using AngularJS and I would like to redirect a user when he clicks a button on /page1 to /page2. I currently use AngularJS routing for this using ngRoute which works all fine. However, in addition to the redirection, I would also like to pass some data from page1 to page2 to pre-populate some of the HTML on page2. I know that in order to pass such data, I can either specify it in the path parameter,e.g.



/page2/<param1>/<param2>


or as a query string parameter, e.g.



 /page2?<key1>=<value1>&<key2=value2>


In both ways, I can retrieve the query string or path params in /page2 using $route.current.params



However, I do not want to do either of the above as I do not want to expose my data on the URL to the user. Is there a way in AngularJS that the parameters can be passed to /page2, such that they are "hidden" from the URL?



Thanks










share|improve this question
























  • You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

    – georgeawg
    Mar 25 at 4:43











  • thanks, using a service worked! if you can add an answer I can accept it.

    – Shrikanth Rajgopalan
    Mar 25 at 6:28













0












0








0








I'm using AngularJS and I would like to redirect a user when he clicks a button on /page1 to /page2. I currently use AngularJS routing for this using ngRoute which works all fine. However, in addition to the redirection, I would also like to pass some data from page1 to page2 to pre-populate some of the HTML on page2. I know that in order to pass such data, I can either specify it in the path parameter,e.g.



/page2/<param1>/<param2>


or as a query string parameter, e.g.



 /page2?<key1>=<value1>&<key2=value2>


In both ways, I can retrieve the query string or path params in /page2 using $route.current.params



However, I do not want to do either of the above as I do not want to expose my data on the URL to the user. Is there a way in AngularJS that the parameters can be passed to /page2, such that they are "hidden" from the URL?



Thanks










share|improve this question
















I'm using AngularJS and I would like to redirect a user when he clicks a button on /page1 to /page2. I currently use AngularJS routing for this using ngRoute which works all fine. However, in addition to the redirection, I would also like to pass some data from page1 to page2 to pre-populate some of the HTML on page2. I know that in order to pass such data, I can either specify it in the path parameter,e.g.



/page2/<param1>/<param2>


or as a query string parameter, e.g.



 /page2?<key1>=<value1>&<key2=value2>


In both ways, I can retrieve the query string or path params in /page2 using $route.current.params



However, I do not want to do either of the above as I do not want to expose my data on the URL to the user. Is there a way in AngularJS that the parameters can be passed to /page2, such that they are "hidden" from the URL?



Thanks







angularjs angularjs-ng-route






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 7:42







Shrikanth Rajgopalan

















asked Mar 25 at 2:54









Shrikanth RajgopalanShrikanth Rajgopalan

156314




156314












  • You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

    – georgeawg
    Mar 25 at 4:43











  • thanks, using a service worked! if you can add an answer I can accept it.

    – Shrikanth Rajgopalan
    Mar 25 at 6:28

















  • You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

    – georgeawg
    Mar 25 at 4:43











  • thanks, using a service worked! if you can add an answer I can accept it.

    – Shrikanth Rajgopalan
    Mar 25 at 6:28
















You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

– georgeawg
Mar 25 at 4:43





You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app. For more information, see AngularJS Developer Guide - Creating Services.

– georgeawg
Mar 25 at 4:43













thanks, using a service worked! if you can add an answer I can accept it.

– Shrikanth Rajgopalan
Mar 25 at 6:28





thanks, using a service worked! if you can add an answer I can accept it.

– Shrikanth Rajgopalan
Mar 25 at 6:28












1 Answer
1






active

oldest

votes


















1














You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app.



app.service("appData", function() 
var myData;
this.set = function(data)
myData = data;
;
this.get = function()
return myData;
;



In a controller:



app.controller("viewCtrl", function($scope,appData) 
$scope.myData = appData.get();

//

appData.set(newData);

);


For more information, see AngularJS Developer Guide - Creating Services.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330692%2fangularjs-ngroute-specify-data-for-target-page-with-data-not-appearing-in-url%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app.



    app.service("appData", function() 
    var myData;
    this.set = function(data)
    myData = data;
    ;
    this.get = function()
    return myData;
    ;



    In a controller:



    app.controller("viewCtrl", function($scope,appData) 
    $scope.myData = appData.get();

    //

    appData.set(newData);

    );


    For more information, see AngularJS Developer Guide - Creating Services.






    share|improve this answer



























      1














      You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app.



      app.service("appData", function() 
      var myData;
      this.set = function(data)
      myData = data;
      ;
      this.get = function()
      return myData;
      ;



      In a controller:



      app.controller("viewCtrl", function($scope,appData) 
      $scope.myData = appData.get();

      //

      appData.set(newData);

      );


      For more information, see AngularJS Developer Guide - Creating Services.






      share|improve this answer

























        1












        1








        1







        You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app.



        app.service("appData", function() 
        var myData;
        this.set = function(data)
        myData = data;
        ;
        this.get = function()
        return myData;
        ;



        In a controller:



        app.controller("viewCtrl", function($scope,appData) 
        $scope.myData = appData.get();

        //

        appData.set(newData);

        );


        For more information, see AngularJS Developer Guide - Creating Services.






        share|improve this answer













        You can use a service to store data that will survive route changes. Services are singletons that persist through the entire life of the app.



        app.service("appData", function() 
        var myData;
        this.set = function(data)
        myData = data;
        ;
        this.get = function()
        return myData;
        ;



        In a controller:



        app.controller("viewCtrl", function($scope,appData) 
        $scope.myData = appData.get();

        //

        appData.set(newData);

        );


        For more information, see AngularJS Developer Guide - Creating Services.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 7:30









        georgeawggeorgeawg

        37.1k115473




        37.1k115473





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330692%2fangularjs-ngroute-specify-data-for-target-page-with-data-not-appearing-in-url%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴