Is there a short way to write the code below (from Rock & Roll with Ember.js book):
export default Ember.Controller.extend({
noSongs: Ember.computed('model.songs.length', function() {
return this.get('model.songs.length') === 0;
}),
(...)
});
I reckon I can desctructure import for Controller, get and computed:
import { Controller, get, computed } from 'ember';
Questions
- Can I use arrow function inside the
computedinstead offunction? - Is there a more javascript-ish way to do
this.get('model.songs.length')as it feels awkward to havelengthas a string?
Aucun commentaire:
Enregistrer un commentaire