samedi 29 août 2015

Emberjs - using computed property

This is what I have in template:

{{check-box isChecked=hasPhoneForSecureAlerts visibleLabelLoc=".t.settingscontact.label.phone" class="checkbox-inline narrow" testId="chk-phone"}}

This is what I have in controller for this property:

hasPhoneForSecureAlerts: Em.computed.bool('securePreferences.phoneLocalNumber'),

Let's assume, that originally this property is set to true and check box is checked, If I uncheck check box, this property is set to false and actually does not correspond to state of securePreferences.phoneLocalNumber.

To set it to initial value, when we are leaving this screen without saving, I just use in resetController at corresponding route:

controller.set('hasPhoneForSecureAlerts', controller.get('securePreferences.phoneLocalNumber') !== null);

Is this code correct? It actually works fine, but I am finding anywhere in Emberjs documentation something like that. Thanks!




Aucun commentaire:

Enregistrer un commentaire