0
votes

I am trying to pass a param in my path. i try like this:

route.js

this.route`enter code here`('purchase', {path: '/purchase'}, function () {
        this.route('purchaseDetails');
        this.route('purchaseEdit', {path:'purchaseEdit?country='}); //showing in the URL
        this.route('purchaseReview');
        this.route('purchaseConfirmation');
      });

redirecting like :

this.transitionTo('purchase.purchaseEdit', "SG");

But not works. any one correct me please?

1

1 Answers

1
votes

It's explained very well here.

You can also do like this. The url will be shown as .../purchase/purchaseEdit/India

this.route('purchase', {path: '/purchase'}, function () {
    this.route('purchaseDetails');
    this.route('purchaseEdit', {path:'purchaseEdit/:country'}); //showing in the URL
    this.route('purchaseReview');
    this.route('purchaseConfirmation');
  });

In the route of purchaseEdit, while getting the model you can get the value of the country.

model:function(params)
{   
    console.log(params); //Contains the dynamic-params declared in the route as object.
    return this.store.find('purchasedItem',params.country).then(function(response){
                return response;
    },function(response){
                return "";
    });
}