我不明白为什么通过@observable这个“属性改变”不起作用,stringValueChanged()方法不会被调用。我在这里错过了什么? (整个绑定在这里不起作用。)
货币control.ts
import { bindable, observable } from 'aurelia-framework';
export class CurrencyControl {
@bindable
value: number;
@observable
stringValue: string;
constructor() {
}
valueChanged(newValue: number, oldValue: number) {
alert('value changed');
}
stringValueChanged(newValue: string, oldValue: string) {
alert('stringValueChanged changed');
}
}
货币control.html
<template>
<require from="./currency-control.css"></require>
<div class="input-group">
<div class="input-group-addon">€</div>
<input type="text" maxlength="5" pattern="\d*" class="form-control" value.bind="stringValue" />
</div>
</template>
答案 0 :(得分:0)
我的错!在使用CurrencyControl的组件中,我需要CurrencyControl的html:
<template>
<require from="../currency-control/currency-control.html"></require>
而不是组件:
<template>
<require from="../currency-control/currency-control"></require>