Last active
March 22, 2017 15:43
-
-
Save LevelbossMike/792d3a7be200a348679a9d35598e951b to your computer and use it in GitHub Desktop.
Route hook order
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'; | |
| const { computed } = Ember; | |
| export default Ember.Controller.extend({ | |
| testModel: computed(function() { | |
| return { "id": "abc" } | |
| }), | |
| actions: { | |
| goTo() { | |
| this.transitionToRoute('/test/def') | |
| } | |
| } | |
| }); |
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'; | |
| const Router = Ember.Router.extend({ | |
| location: 'none', | |
| rootURL: config.rootURL | |
| }); | |
| Router.map(function() { | |
| this.route('test', {path: '/test/:id'}) | |
| }); | |
| 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({ | |
| serialize(model, paramsNames) { | |
| console.log('serialize'); | |
| return { id: model.id }; | |
| }, | |
| activate() { | |
| console.log('activate'); | |
| this._super(...arguments); | |
| }, | |
| beforeModel() { | |
| console.log('beforeModel'); | |
| this._super(...arguments); | |
| }, | |
| model(params) { | |
| console.log(`model - params: ${JSON.stringify(params)}`); | |
| const id = params.id | |
| return Ember.Object.create({ id }); | |
| }, | |
| afterModel() { | |
| console.log('afterModel'); | |
| this._super(...arguments); | |
| }, | |
| setupController() { | |
| console.log('setupController'); | |
| this._super(...arguments); | |
| }, | |
| renderTemplate() { | |
| console.log('renderTemplate'); | |
| this._super(...arguments); | |
| }, | |
| deactivate() { | |
| console.log('deactivate'); | |
| this._super(...arguments); | |
| } | |
| }); |
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.10.6", | |
| "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.9.0", | |
| "ember-data": "2.9.0", | |
| "ember-template-compiler": "2.9.0", | |
| "ember-testing": "2.9.0" | |
| }, | |
| "addons": {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment