0

Url:192.168.0.40/index.html?code1=123#/cases/?code2=4567

How can get Code1 and Code2 from url?

My Code

App.CasesRoute = Ember.Route.extend({

    model: function(params) {  
        var code1=params.queryParams.code1;
        var code1=params.queryParams.code2;
    }
})

I can get code2 but code1 is undefined? this.store is null

please help me

ashkufaraz
  • 5,179
  • 6
  • 51
  • 82
  • 1
    Are you sure you get `code2`? I'd expect only `code1` to be set, since the hash probably wouldn't be submitted as part of the request query. Unless there's something special I'm missing right now. – Mario Aug 04 '15 at 05:39
  • Should be `params.code1` but before you need specify that you route has query params. [here](http://guides.emberjs.com/v1.10.0/routing/query-params/) more details. – DeivinsonTejeda Aug 05 '15 at 12:23

1 Answers1

1

If you can get code2, I will assume you are using the Router with location property set to hash, which means the code1 query parameter is not parsed by the Ember application.

You can however parse the global location.search, which will work.

Getting a query parameter value is explained here: How can I get query string values in JavaScript?

Community
  • 1
  • 1
dashdashzako
  • 1,268
  • 15
  • 24