Skip to content

Instantly share code, notes, and snippets.

@feanor07
Forked from kumkanillam/controllers.application.js
Last active August 15, 2016 05:31
Show Gist options
  • Save feanor07/1fe2f599e300aacf7028f35aad1eb9ab to your computer and use it in GitHub Desktop.
Save feanor07/1fe2f599e300aacf7028f35aad1eb9ab to your computer and use it in GitHub Desktop.
StackOverflow Answer: 38940408
import Ember from 'ember';
export default Ember.Component.extend({
actions:{
changeAppAtComponent(){
this.set('appName','Kumkanillam');
}
}
});
import Ember from 'ember';
const {computed,observer} = Ember;
export default Ember.Controller.extend({
myService:Ember.inject.service(),
appName: 'Ember Twiddle',
changedAppName:observer('appName',function(){
this.get('myService').changeAppName(this.get('appName'));
}),
actions:{
changeApp(){
this.set('appName','NewEmberApp');
}
}
});
import Ember from 'ember';
export default Ember.Service.extend({
appName:'SSS',
changeAppName(param){
this.set('appName',param);
}
});
<h1>Welcome to {{myService.appName}}</h1>
<br>
<button {{action "changeApp"}}>Change at Controller</button>
<br>
{{outlet}}
<br>
<br>
{{my-component appName=appName}}
<button {{action "changeAppAtComponent"}}>Change at Component</button>
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment