Skip to content

Instantly share code, notes, and snippets.

@mydea
Created August 14, 2018 06:42
Show Gist options
  • Save mydea/7caba6683b713fc8e9e436e35a1de395 to your computer and use it in GitHub Desktop.
Save mydea/7caba6683b713fc8e9e436e35a1de395 to your computer and use it in GitHub Desktop.
Test ED model.hasOwnProperty('id')
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
check: Ember.computed(function() {
let item = this.store.createRecord('item', { name: 'John'});
return {
hasId: item.hasOwnProperty('id'),
hasName: item.hasOwnProperty('name')
};
})
});
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
export default Model.extend({
name: attr('string')
});
<h1>Test hasOwnProperty</h1>
<div>
Has Id: {{check.hasId}}
</div>
<div>
Has Name: {{check.hasName}}
</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.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment