Skip to content

Instantly share code, notes, and snippets.

@vinilios
Created October 3, 2016 16:20
Show Gist options
  • Save vinilios/491784598b762ee046a60f0145514960 to your computer and use it in GitHub Desktop.
Save vinilios/491784598b762ee046a60f0145514960 to your computer and use it in GitHub Desktop.
strange-cp-updates
import Ember from 'ember';
const {
set, get, on, computed
} = Ember;
const MyClass = Ember.Object.extend({
fullname: computed('profile', 'profile.name', 'profile.surname', function() {
console.log("resolve fullname");
return get(this, 'profile.name') + ' ' + get(this, 'profile.surname');
}),
toStringExtension() {
console.log("toString");
return get(this, 'fullname');
}
});
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
setModel: on('init', function() {
let model = MyClass.create({
profile: Ember.Object.create({
name: 'myname',
surname: 'mysurname'
})
});
let model2 = model.constructor.create({
profile: model.get('profile')
});
set(this, 'model', model2);
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{ model.fullname }}
<br>
<br>
{
"version": "0.10.5",
"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.8.0",
"ember-data": "beta",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment