Angularjs are missing parameters, so they are hidden

I would like to know what is the best (and most secure) way to pass parameters (such as product id) between views so that the user cannot see them in the url bar.

Thank. Stephan

+3


source to share


3 answers


You have to pass them from one controller to another controller in a new view. Here's a pretty good answer on how to do it: LINK



+1


source


Store them in a shared service and use them when you need it, quick example:

app.factory("shared", function() {
    var data = null;
    return {
        setData: function(someData) {
            data = someData;
        },
        getData: function() {
            return data;
        }
    }
});

      



And now use it!

app.controller("myCtrl", function($scope, shared) {
    $scope.data = shared.getData();
});

      

+1


source


A good way to do this is by using the Angular service template. Since controllers are functions and services are objects (single-point), you can have multiplexing services according to the different functionality you have in your application.

You should see the documentation for Angular providers here: https://docs.angularjs.org/guide/providers

0


source







All Articles