An example of functions.
Please check init. Init is executed when the class is created. Please check that you can change the properties of the class when you create an object based on this class; init function will be executed after that.
import Ember from 'ember'; | |
let consoleTrace = []; | |
const ForceUserCharacter = Ember.Controller.extend({ | |
name: 'User of the force', | |
weapon: 'Standard lightsaber', | |
init() { | |
consoleTrace.push(`I'm ${this.get('name')} and I have this ${this.get('weapon')}`); | |
} | |
}) | |
const forceUserCharacter = ForceUserCharacter.create(); | |
const anakinCharacter = ForceUserCharacter.create({ | |
name: 'Anakin Skywalker', | |
weapon: 'Blue lightsaber' | |
}); | |
export default Ember.Controller.extend({ | |
consoleTrace: consoleTrace | |
}); |
{ | |
"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": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |