Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Last active June 19, 2017 01:55
Show Gist options
  • Save kumkanillam/c75a27e5ff373add2c55233c0f8733e5 to your computer and use it in GitHub Desktop.
Save kumkanillam/c75a27e5ff373add2c55233c0f8733e5 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Component.extend({
name:'mycomp',
init(){
this._super(...arguments);
console.log(' init mycomponent');
},
didReceiveAttrs(){
console.log('didReceiveAttrs mycomponent');
},
didUpdateAttrs(){
console.log('didUpdateAttrs mycomponent');
},
willUpdate(){
console.log('willUpdate mycomponent');
},
didInsertElement(){
console.log('didInsertElement mycomponent');
},
didUpdate(){
console.log('didUpdate mycomponent');
},
willRender(){
console.log('willRender mycomponent');
},
didRender(){
console.log('didrender mycomponent');
},
actions:{
toChange(){
this.set('name','ChangedInMyComp '+new Date().toISOString());
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
name:'mycomp2',
cities: ['Barcelona', 'London', 'New York', 'Porto'],
destination: 'London',
init(){
this._super(...arguments);
console.log(' init mycomponent2');
},
didReceiveAttrs(){
console.log('didReceiveAttrs mycomponent2');
},
didUpdateAttrs(){
console.log('didUpdateAttrs mycomponent2');
},
willUpdate(){
console.log('willUpdate mycomponent2');
},
willRender(){
console.log('willRender mycomponent2');
},
didUpdate(){
console.log('didUpdate mycomponent2');
},
didInsertElement(){
console.log('didInsertElement mycomponent2');
},
didRender(){
console.log('didrender mycomponent2');
},
actions:{
toChange(){
this.set('name','ChangedInMyComp '+new Date().toISOString());
},
chooseDestination(city) {
this.set('destination', city);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
<div id="ember-basic-dropdown-wormhole"></div>
<br>
{{#my-component as |name toChange|}}
<button {{action toChange}}> 1 - {{name}}</button>
{{#my-component2 as |name toChange|}}
<button {{action toChange}}> 2 - {{name}}</button>
{{/my-component2}}
{{/my-component}}
<br>
{{outlet}}
<br>
{{yield name (action 'toChange')}}
{{#power-select
selected=destination
options=cities
onchange=(action "chooseDestination")
as |name|
}}
{{name}}
{{/power-select}}
{{yield name (action 'toChange')}}
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-power-select": "1.8.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment