I want to have a url like this /restaurants/:pageNumber
and I want /restaurants
to assume the pageNumber parameter is 1.
Here is my Router.js
:
Router.map(function() {
this.route('restaurants', function() {});
this.route('restaurants', { path: '/restaurants/:pageNumber' }, function() {});
});
If it remove the function() {}
for it, I just get a blank page with no errors in the console for /restaurants/1
My routes/restaurants/index.js
:
export default Ember.Route.extend({
ajax: Ember.inject.service(),
model(params) {
return Ember.RSVP.hash({
response: this.get('ajax').request('/getAllRestaurants', {method: 'GET'}),
currentPage: params.pageNumber | 1
});
}
});
On the templates/restaurants/index.hbs
I check and it's always 1
. If I remove the | 1
it's undefined
.
Aucun commentaire:
Enregistrer un commentaire