1

i'm trying to pass 2 variables with $routeProvider :

.when('/edition_etude/:idEtude/:domaine', {
    templateUrl: 'vues/edition_etude.html',
    controller: 'edition_etude'
})

And my function :

$scope.editionEtude= function(etude) {
    var idEtude = etude.id_etude;
    $location.path('/edition_etude/'+idEtude+'&domaine='+domaine);
}

Finallly, i'm supposed to get the 2 variable in the destination contrlller like this :

monApp.controller("edition_etude", function($scope,$http,$routeParams,serviceDepartements,serviceEnseignes,serviceType_etude,serviceRegions,serviceMaxid,serviceCategorie_magasin) {

var idEtude = $routeParams.idEtude;
var domaine = $routeParams.domaine; 

It works very well as long as i use 1 variable, but doesent work as soon as i try 2 variables .

This is the code when its working :

$routeProvider.when('/edition_etude/:idEtude', {
    templateUrl: 'vues/edition_etude.html',
    controller: 'edition_etude'
});

Then the controller who fires the event:

$scope.editionEtude     = function(etude){
    var idEtude = etude.id_etude;
    $location.path('/edition_etude/'+idEtude);
}

And finally im getting correctly the idEtude ar in y new controller here :

var idEtude = $routeParams.idEtude;

I don't want to use a service! it's NOT a duplicate, I checked all others answers!

2 Answers 2

1
$location.path('/edition_etude/'+idEtude+'/'+domaine);

You don't have to specify the name of the params

Sign up to request clarification or add additional context in comments.

1 Comment

Don't forget to set the question to answered, so people can see that it's been resolved.
0

Your issue came from your path call.

Your route is:

.when('/edition_etude/:idEtude/:domaine', {
    templateUrl: 'vues/edition_etude.html',
    controller: 'edition_etude'
})

So your URL should be

$location.path('/edition_etude/' + idEtude + '/' + domaine);

instead of

$location.path('/edition_etude/'+idEtude+'&domaine='+domaine);

Comments

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.