Skip to content

Instantly share code, notes, and snippets.

@yonjah
Created June 2, 2016 06:57
Show Gist options
  • Save yonjah/af5acf8f27cc56fee7216e588126a8d0 to your computer and use it in GitHub Desktop.
Save yonjah/af5acf8f27cc56fee7216e588126a8d0 to your computer and use it in GitHub Desktop.
loading state
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('next', {path: '/next'});
this.route('last', {path: '/last'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
/*model: function () {
return new Ember.RSVP.Promise(function (res, can) {
window.setTimeout(res.bind(null, {}), 1000);
});
}
*/
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function (params, transition) {
return new Ember.RSVP.Promise(function (res, can) {
window.setTimeout(can.bind(null, new Error()), 1000);
}).catch(function (e) {
transition.abort();
throw e;
});
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function (params, transition) {
return new Ember.RSVP.Promise(function (res, can) {
window.setTimeout(can.bind(null, new Error()), 1000);
});
}
});
<h1>Welcome to {{appName}}</h1>
{{#link-to 'index'}}home{{/link-to}} {{#link-to "next"}}next{{/link-to}} {{#link-to "last"}}last{{/link-to}}
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.8.1",
"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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment