I’m migrating a project from Aurelia 1 to Aurelia 2, and I’m unable to replicate the capabilities of the @computedFrom(‘xxxx’) decorator.
The code I’m trying to replicate looks like this:
@observable Type_RTK: string;
@computedFrom("Type_RTK")
get TypeAbbreviation(): string
{
let rtk = GetLoadTypeRtkInfo(this.Type_RTK);
if (rtk)
return rtk.abbreviation.toUpperCase();
return "";
}
I’ve tried solutions with @computed, @watch, @bindable, and no decorator but never am able to have the get method fire.
Here are some examples that fail to fire when the observable property this.Type_RTK is changed. I’ve moved the code that sets this.Type_RTK from bound() to attached() as well with no luck.
get TypeAbbreviation(): string
{
let rtk = GetLoadTypeRtkInfo(this.Type_RTK);
if (rtk)
return rtk.abbreviation.toUpperCase();
return "";
}
@bindable({ mode: BindingMode.default }) get TypeAbbreviation(): string {
debugger;
const rtk = ShippingDtos.ShipmentTypeRTKs.GetLoadTypeRtkInfo(this.Type_RTK);
return rtk ? rtk.abbreviation.toUpperCase() : '';
}
I could really use some guidance here, I’ve spent about a day trying to figure this out. Thanks.