Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#link-to 'wizard'}}Start Wizard{{/link-to}}
<br>
<br>
{{outlet}}
import DS from 'ember-data';
export default DS.Model.extend({
field1: DS.attr('string'),
field2: DS.attr('string')
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('wizard', function() {
this.route('step1');
this.route('step2');
});
});
export default Router;
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
console.info('wizard#model()');
return this.store.createRecord('test');
},
afterModel(model, transition) {
console.info('wizard#afterModel()', model, transition.targetName);
if(transition.targetName === 'wizard.index') {
this.transitionTo('wizard.step1');
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
console.info('wizard.step1#model()');
this.set('wizard', this.modelFor('wizard'));
return null;
},
setupController(controller, model) {
this._super(controller, model);
controller.set('wizard', this.get('wizard'));
}
});
<h1>Step 1</h1>
{{input value=wizard.field1}}
{{#link-to 'wizard.step2'}}To step 2{{/link-to}}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
console.info('wizard.step2#model()');
this.set('wizard', this.modelFor('wizard'));
return null;
},
setupController(controller, model) {
this._super(controller, model);
controller.set('wizard', this.get('wizard'));
}
});
<h1>Step 2</h1>
{{input value=wizard.field2}}
{{#link-to 'wizard.step1'}}Back to step 1{{/link-to}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment