Reputation: 35
I have the following object:
{
types: ["Type A", "Type B", "Type C"],
colours: ["Red", "Blue", "Black"]
}
which I send as parameter to a component
export default Ember.component.extend({
tableContent: function(){
const keys = Object.keys(this.get('config'));
if (keys.length > 1){
let array = [];
keys.shift();
keys.forEach((element) => {
array.pushObject({name: element});
});
return array;
}
}.property('config')
I want to be able to listen for changes when creating a new addition. Ex:
{
types: ["Type A", "Type B", "Type C"],
colours: ["Red", "Blue", "Black", "Yellow"].
lang: ["en","fr","es"]
}
I have tried using .property('config.@each') but it wont work.
Any ideas? Thanks.
Upvotes: 1
Views: 32
Reputation: 12872
config
is an object, so config.types.@each
will work.
You can listen for all config.types.@each
config.colours.@each
config.lang.@each
or it can be shortened to something like this config.{types,colours,lang}.@each
Refer : https://guides.emberjs.com/v2.16.0/object-model/computed-properties-and-aggregate-data/
Upvotes: 1