I have a component property in my component.js based on which i will show/hide some data in template.hbs
Case1: By default the componentProperty (canShow
) is true, but based on some change in data it will be set false in another computed property
.
dataChanged: computed( 'data', 'canShow', function () {
if(it is true) {
this.set('canShow', false);
}
});
Expected: Canshow
should be false, so the data in template should be hidden Result: It is getting updated as false, But in template the data is still showing
Case2: I have tried this with getter and setter in computed.
canShowTemplateData: computed('canShow', {
get() {
return this.get('canShow');
},
set(key, value) {
return value;
}
});
Even in this case, set is working fine. But the value is not at all updated in template using get() function. Also pls clarify while using set(), which value should be updated either canShow
or canShowTemplateData
?
Am I missing something? Or is there any other way to handle this?
Aucun commentaire:
Enregistrer un commentaire