0

I trying to call other route in angular, similar this

$location.path($scope.productPath+"/approveProducts/").search({ids});

I want send the list of ids to other controller but the ids are sending by url

http://localhost:8080/#/product?ids=1130&ids=1132&ids=7428&ids=15574&ids=15579&ids=15580&ids=6798968768697789

I need send ids similar a post requisition, not in a url, because i have a many ids in my call

How i do this in angular, send parameters and change my route to other controller?

2 Answers 2

1

I believe a better approach might be to utilize the angularjs service/factory to persist your data.

example:

.service('AngularJsService', function() {
    var listOfIds = [];
    return {
       saveData: function(theIdsToSave) {
          listOfIds = theIdsToSave;
       },
       getData: function () {
          return listOfIds;
       }
    }
}
.controller('OriginatingController', function($location, AngularJsService) {
    function navigateToTargetController() {
       AngularJsService.saveData([1,2,3,4]);
       $location.path('pathToTargetController');
    }
}
.controller('TargetController', function($location, AngularJsService) {
    function retrieveData() {
       var ids = AngularJsService.getData();
       // ids = [1,2,3,4]
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use $http for send your params and then change your route

var req = {
 method: 'POST',
 url: 'http://example.com',// address for sending ids
 headers: {
   'Content-Type': undefined
 },
 data: { test: 'test' }
}

$http(req).then(function(){
    // this you can to change your url
    $location.path($scope.productPath+"/approveProducts/");
}, function(){...});

1 Comment

thanks but I need change the route, send parameters to other controller

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.