While migrating my apps to Aurelia 2, I noticed strange behavior with the binding for the translation attribute, t
. Here is simplified example:
<div if.bind="obj">
<span t.bind="obj.property"></span>
</div>
If the object (obj
) disappears, i.e., if it is set to null, the binding (t.bind
) throws the error: “AUR0203: Trying to retrieve a property or build a scope from a null/undefined scope”. I thought that if.bind
on the parent element would take care of that, meaning div would be removed from the DOM and binding would not happen if there is no obj
, as was the case in Aurelia 1.
It works if I use the same expression in the getter in the view-model, and bind the t
attribute to that getter. However, this approach is much less flexible. I don’t understand what’s going on or how to make it work as before. I would appreciate any help. Thanks!
[Edit] Another real world example. This code throws the AUR0203:
<span t.bind="invitation.relationTypeId | userType"></span>
And this works:
<span>${invitation.relationTypeId | userType | t}</span>