Skip to content

Instantly share code, notes, and snippets.

@vigor-rus
Last active July 20, 2019 17:35
CP access
import Ember from 'ember';
import EmberObject, { computed } from '@ember/object';
import { dasherize } from '@ember/string';
let Band = EmberObject.extend({
name: '',
language: '',
slug: computed('name', function() {
console.log('Recomputing slug');
return dasherize(this.name);
}),
site: computed('slug', 'language', function() {
console.log('Recomputing site');
return `https://bands.com/${this.slug}.${this.language}`;
})
});
let band = Band.create({ name: 'Mookie Blaylock', language: 'jsp' });
console.log(1, band.site);
console.log(2, band.site);
band.set('name', 'Pearl Jam');
console.log(3, band.site);
band.set('language', 'php');
console.log(4, band.site);
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.15.1",
"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.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment