Forked from ykaragol/controllers.primitive-object-example.js
Last active
April 10, 2017 13:26
-
-
Save feanor07/937c455204fc72a8af2f0e218ac66930 to your computer and use it in GitHub Desktop.
Using query-params at routes
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.Component.extend({ | |
actions: { | |
triggerUrlUpdate() { | |
this.get('triggerUrlUpdate')(); | |
} | |
} | |
}); |
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'; | |
var object = Ember.Object.create({ | |
isQueryParams: true, | |
values: {foo1: 'eq.id.value=3;eq.odemeSurecTuru.value=a'} | |
}); | |
export default Ember.Controller.extend({ | |
myparams: object, | |
routeParams: { | |
'eq.id.value': 3 | |
} | |
}); |
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({ | |
queryParams:{ | |
direction:{}, | |
count:{ | |
refreshModel:true | |
}, | |
currentDate: {} | |
}, | |
actions:{ | |
incrementCount:function(){ | |
this.incrementProperty('count'); | |
} | |
} | |
}); |
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 function myHelper(params, hash) { | |
console.log(params); | |
console.log(hash); | |
return params; | |
} | |
export default Ember.Helper.helper(myHelper); |
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('foo-route'); | |
this.route('primitive-object-example'); | |
this.route('array-example'); | |
this.route('javascript-object-example'); | |
this.route('dynamic-segments-and-query-params-example', {path:'/dsqpe/:id1/:id2'}); | |
}); | |
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({ | |
model(){ | |
return { | |
sampleDate:new Date(), | |
sampleArr:[{x:2,y:3},{x:4,y:6},{x:6,y:12}], | |
sampleObj:{x:2,y:3} | |
} | |
} | |
}); |
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({ | |
queryParams:{ | |
arr:{ | |
type:'array' | |
} | |
} | |
}); |
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({ | |
queryParams:{ | |
direction:{}, | |
count:{}, | |
currentDate: {} | |
}, | |
model(params, transition){ | |
return { | |
direction:params.direction, | |
id1:params.id1, | |
id2:params.id2 | |
} | |
} | |
}); |
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({ | |
queryParams: { | |
foo1: { | |
//refreshModel: true, | |
//scope: 'controller' | |
} | |
}, | |
model(params) { | |
console.log('@model' + this.controllerFor(this.get('routeName')).get('foo1')); | |
Ember.run.scheduleOnce('routerTransitions', this, ()=>this.controllerFor(this.get('routeName')).set('foo1', undefined)); | |
return params.foo1 + "-" + Math.random(); | |
}, | |
actions: { | |
triggerUrlUpdate() { | |
this.controllerFor(this.get('routeName')).set('foo1', Math.random()); | |
this.refresh(); | |
} | |
} | |
}); |
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({ | |
queryParams:{ | |
complex:{} | |
} | |
}); |
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({ | |
queryParams:{ | |
count:{ | |
refreshModel:true | |
}, | |
}, | |
model(){ | |
console.log('model called'); | |
} | |
}); |
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.7", | |
"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.10.0", | |
"ember-data": "2.10.0", | |
"ember-template-compiler": "2.10.0", | |
"ember-testing": "2.10.0" | |
}, | |
"addons": { | |
"ember-route-action-helper": "2.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment