Last active
October 19, 2015 14:25
-
-
Save koriroys/f939eb387d2b8626b893 to your computer and use it in GitHub Desktop.
Current Route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
throw new DS.InvalidError([ | |
{ | |
source: { pointer: 'data/attributes/first_name' }, | |
detail: 'is invalid' | |
} | |
]); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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