Last active
May 17, 2018 19:45
-
-
Save jamesarosen/ad1ca8f413bc17fb1b4d679d56996000 to your computer and use it in GitHub Desktop.
query-params-debugging
This file contains 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'; | |
console.clear() | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
clearLog() { | |
this.get('log').clear() | |
}, | |
foo: undefined, | |
incrementFoo() { | |
this.get('log').append('foo++') | |
const foo = parseInt(this.get('foo') || 0) | |
const router = this.get('router') | |
router.transitionTo(router.currentRouteName, { queryParams: { foo: foo + 1 } }) | |
}, | |
log: Ember.inject.service(), | |
queryParams: ['foo'], | |
router: Ember.computed(function() { | |
return Ember.getOwner(this).lookup('router:main') | |
}) | |
}); |
This file contains 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({ | |
bar: undefined, | |
queryParams: ['bar'], | |
}); |
This file contains 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('child') | |
}); | |
export default Router; |
This file contains 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({ | |
log: Ember.inject.service(), | |
init() { | |
this._super(...arguments) | |
this.get('log').append(`Ember ${Ember.VERSION}`) | |
}, | |
beforeModel() { | |
this.get('log').append('route:application#beforeModel') | |
}, | |
model(params, transition) { | |
this.get('log').append(`route:application#model ${transition.queryParams.foo}`) | |
}, | |
afterModel() { | |
this.get('log').append('route:application#afterModel') | |
}, | |
setupController() { | |
this.get('log').append('route:application#setupController') | |
return this._super(...arguments) | |
}, | |
queryParams: { | |
foo: { | |
refreshModel: true | |
} | |
} | |
}); |
This file contains 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({ | |
log: Ember.inject.service(), | |
beforeModel() { | |
this.get('log').append('route:child#beforeModel') | |
}, | |
model(params, transition) { | |
this.get('log').append(`route:child#model ${transition.queryParams.foo}`) | |
}, | |
afterModel() { | |
this.get('log').append('route:child#afterModel') | |
}, | |
setupController() { | |
this.get('log').append('route:child#setupController') | |
return this._super(...arguments) | |
}, | |
}); |
This file contains 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.Service.extend({ | |
content: Ember.computed(function() { | |
return [] | |
}), | |
append(msg) { | |
this.set('content', this.get('content').concat(msg)) | |
}, | |
clear() { | |
this.set('content', []) | |
}, | |
}); |
This file contains 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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
a, a:focus, a:hover, a:visited { | |
color: blue; | |
} | |
a.active { | |
color: green; | |
} |
This file contains 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.13.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.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