Skip to content

Instantly share code, notes, and snippets.

@3gwebtrain
Last active February 19, 2018 13:14
Show Gist options
  • Save 3gwebtrain/839e8a5766efc5a69afb2ffe712eec8b to your computer and use it in GitHub Desktop.
Save 3gwebtrain/839e8a5766efc5a69afb2ffe712eec8b to your computer and use it in GitHub Desktop.
Page Number
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
pageService:Ember.inject.service(),
actions:{
pageHandler:function(){
var pageNo = this.get('pageService').get('pageIndex');
var totalPages = this.get('pageService').get('totalPages');
this.set('totalPages', totalPages);
this.set('pageNo', pageNo);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
pageService:Ember.inject.service(),
actions:{
pageHandler:function(){
var pageNo = this.get('pageService').get('pageIndex');
var totalPages = this.get('pageService').get('totalPages');
this.set('totalPages', totalPages);
this.set('pageNo', pageNo);
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('page-one');
this.route('page-two')
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
model(){
this.controllerFor(this.routeName).send('pageHandler');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model(){
this.controllerFor(this.routeName).send('pageHandler');
}
});
import Ember from 'ember';
export default Ember.Service.extend({
pageIndex:1,
totalPages:2
});
<h1>Welcome to {{appName}}</h1>
{{#link-to "page-one"}}Page One{{/link-to}}
{{#link-to "page-two"}}Page One{{/link-to}}
<br>
<br>
{{outlet}}
<br>
<br>
<h2>Page one</h2> Page No. {{pageNo}} of {{totalPages}}
<h2>Page one</h2> Page No. {{pageNo}} of {{totalPages}}
{
"version": "0.13.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment