The interacting one works by adding a getter and setter to its resource, which it uses to observe the changes. He recommended using a callback method ${propertyName}Changed(newValue, oldValue)to accomplish what you are trying to do. Here is an example of ES2016:
ViewModel
import {bindable} from 'aurelia-framework';
export class MyCustomElement {
@bindable name;
_name;
errorMessage = '';
nameChanged(newValue) {
if(newValue.length >= 5 ) {
this.errorMessage = 'Name is too long';
}
else {
this._name = newValue;
this.errorMessage = '';
}
}
}
View
<template>
<p>Name is: ${_name}</p>
<p>Error is: ${errorMessage}</p>
</template>
, ES2016 , . , TypeScript, , , name nameChanged. , newValue this._name .