gokatz
1/12/2017 - 5:11 PM

ember assert: create with _super

ember assert: create with _super

{
  "version": "0.10.7",
  "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.2.2",
    "ember-data": "2.10.0",
    "ember-template-compiler": "2.2.2",
    "ember-testing": "2.2.2"
  },
  "addons": {}
}
<h1>Welcome to {{appName}}</h1>
<br>
<button {{action 'testCreateMethod'}}>User Age</button>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';

export default Ember.Object.extend({
  name: 'Parent',
  ageCriteria(agePhrase) {
  	return 'The user is ' + agePhrase;
  }
});
import Ember from 'ember';
import parentModel from 'app/models/parent';

export default parentModel.extend({
  name: 'Child',
  age: 20,
  ageCriteria() {
    let phrase;
  	if(this.get('age') > 18) {
    	phrase = '+18';
    } else {
      phrase = 'Under 18';
    }
    return this._super(phrase);
  }
});
import Ember from 'ember';
import childModel from 'app/models/child';

export default Ember.Controller.extend({
  appName: 'Ember Twiddle',
  completeAgePhrase: '',
  actions: {
  	testCreateMethod() {
      let childModelInstance = childModel.create();
      console.log(childModelInstance.toString())
    	let newUser = childModel.create(childModelInstance);
      let completeAgePhrase = newUser.ageCriteria();
      console.log(completeAgePhrase)
      this.set('completeAgePhrase', completeAgePhrase);
    }
  }
});