I use ember-cli-pagination lib in my work and i have got one of those route/controllers:
// routes/restaurants/index.js
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
import PaginationRouteMixin from 'ember-cli-pagination/remote/route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, PaginationRouteMixin, {
model: function (params) {
return this.findPaged('restaurant', params);
}
});
// controllers/restaurants/index.js
import Ember from 'ember';
export default Ember.ObjectController.extend({
queryParams: ['page'],
page: 1
pageBinding: "content.page",
totalPagesBinding: "content.totalPages",
});
Here's my router:
// router.js
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
export default Router.map(function() {
this.resource('restaurants', function () {
this.route('index', { path: '/:page' });
this.route('new');
});
this.route('login');
});
What i'm trying to do is to display the URL in this way:
- /restaurants - for page 1
- /restaurants/n - for page number N
But the closest thing i can get to is only one-way binding: when i type URL like above i get the proper page, but when i switch between the pages, i get following URL:
/restaurants/2?page=1
Is there any way to make it work? I would also accept the answer "YOU DON'T GET THE REST WAY, DUDE IT'S SUPPOSED TO BE SO".
Aucun commentaire:
Enregistrer un commentaire