Skip to content

Instantly share code, notes, and snippets.

@manufitoussi
Last active September 20, 2018 08:32
Show Gist options
  • Select an option

  • Save manufitoussi/9dba32465b451f67368b0868e29e7f7f to your computer and use it in GitHub Desktop.

Select an option

Save manufitoussi/9dba32465b451f67368b0868e29e7f7f to your computer and use it in GitHub Desktop.
Test Values in prototype
import Ember from 'ember';
var MyObj = Ember.Object.extend({
obj: Ember.computed({
get() {
var Obj = class Obj {
};
Obj.prototype.get = function(key) {
console.log('get()', key);
// if(this.hasOwnProperty(key)) return Ember.get(this, key);
// return 'coucou';
return Ember.get(this, key)
};
Obj.prototype.prop1 = 'default1';
Obj.prototype.prop2 = 'default2';
Obj.prototype.prop3 = 'default3';
Obj.prototype.prop4 = 'default4';
return new Obj()
}
}).readOnly()
});
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super();
this.myObj = MyObj.create();
this.myObj.obj.prop1 = 1;
Ember.set(this.myObj, 'obj.prop2', 2);
Ember.set(this, 'myObj.obj.prop2', 3);
console.log('this.myObj.obj.prop1', this.myObj.obj.prop1);
console.log('this.myObj.obj.prop2', this.myObj.obj.prop2);
console.log('this.myObj.obj.prop3', this.myObj.obj.prop3);
console.log('this.myObj.obj.prop4', this.myObj.obj.prop4);
console.log('this.myObj.obj', this.myObj.obj);
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<div>
<label>myObj.obj:</label> {{myObj.obj.prop1}}
</div>
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment