Question: I have two classes and want to update a variable in the View of one class by calling a class from another class. Let me elaborate.
thisClass.js:
import {inject} from "aurelia-framework";
import {OtherClass} from "/otherClass";
@inject(OtherClass)
export class ThisClass {
constructor(otherClass){
this.otherClass = otherClass;
}
callLoader(){
this.message = "Hi There!";
this.otherClass.changeMessage(this.message);
}
}
otherClass.js:
export class OtherClass {
constructor(){
this.oldMessage = "";
}
activate(){
this.oldMessage = "Yo!";
}
changeMessage(message){
this.oldMessage = message;
}
}
otherClass.html
<template>
${oldMessage}
</template>
I know the new message is being brought over because when I do a console.log in changeMessage for the passed in message I can see it but the View isn't updating with the new message. Any help would be greatly appreciated.