I am learning how Aurelia works and I am trying to get a simple user attribute. All he will do is change the color of the div text depending on the change in value.
I have a div that has:
high.bind="changeColor"
and in my attribute I:
import {inject, customAttribute} from 'aurelia-framework'; @customAttribute('high') @inject(Element) export class High { constructor(element) { this.element = element; } valueChanged(newValue){ console.log(newValue); if (newValue) { this.element.classList.remove('highlight-yellow'); } else { this.element.classList.add('highlight-blue'); } }
In my opinion, I have a model:
import {high} from './highlightattribute' export class Welcome{ heading = 'Welcome to the Aurelia Navigation App!'; firstName = 'John'; lastName = 'Doe'; get fullName(){ return `${this.firstName} ${this.lastName}`; } get changeColor(){ if (this.firstName == 'John'){ return false; } return true; } welcome(){ alert(`Welcome, ${this.fullName}!`); } }
When I change the first name, I don't see how the valueChanged event is fired in the high user attribute class.
source share