emberjs-essentials
emberjs-essentials copied to clipboard
Ember.ObjectController deprecated chapter5
Hello. Ember.ObjectController is now deprecated so how I can implement this features now?
import Ember from "ember";
export default Ember.ObjectController.extend({
formattedPrice: function(){
returnthis.get('symbol') + "
" +
$.number(this.get('price'),2);
}.property('symbol','price'),
formattedDimension: function(){
return this.get('dimensions.width') + " x " +
this.get('dimensions.height') + " x " +
this.get('dimensions.length');
}.property('dimensions.width','dimensions.height',
'dimensions.length'),
shortDescription: function(){
varshortDesc = this.get('description').substring(0, 25);
returnshortDesc + "...";
}.property('description')
});
Used this in the same controller app/controllers/products.js the following code, but no result was given.
It's just raises errors. Looking forward to your answer.
Well the computed properties are still valid on any ember obect
https://guides.emberjs.com/v2.4.0/object-model/computed-properties/
Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: Ember.computed('firstName', 'lastName', function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
})
});
var ironMan = Person.create({
firstName: 'Tony',
lastName: 'Stark'
});
ironMan.get('fullName'); // "Tony Stark"
see here. https://guides.emberjs.com/v2.4.0/object-model/computed-properties/
@suchitpuri thanks for answer, I will try