Skip to content

Instantly share code, notes, and snippets.

@koriroys
Last active October 19, 2015 14:25
Show Gist options
  • Save koriroys/f939eb387d2b8626b893 to your computer and use it in GitHub Desktop.
Save koriroys/f939eb387d2b8626b893 to your computer and use it in GitHub Desktop.
Current Route
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{link-to 'books' 'books'}}
<p>{{outlet}}</p>
<br>
<br>
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('books', { path: '/books' }, function() {});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
_routing: Ember.inject.service('-routing'),
currentRouteName: Ember.computed.reads('_routing.currentRouteName'),
// currentRouteName will be undefined if we get an error at the application route level
// not the most ideal API, but let's go with what we have
// returns true if currentRouteName is undefined or null
isFirstRoute: Ember.computed.none('currentRouteName'),
model: function(params) {
throw new DS.InvalidError([
{
source: { pointer: 'data/attributes/title' },
detail: 'cannot be blank'
}
]);
},
actions: {
error: function(error, transition) {
debugger
if ( this.get('isFirstRoute') ) {
this.transitionTo('index');
} else{
return true;
}
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
throw new DS.InvalidError([
{
source: { pointer: 'data/attributes/first_name' },
detail: 'is invalid'
}
]);
}
});
List of books here
{
"version": "0.4.13",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment