组件和子组件之间的 Aurelia 绑定不反映更改

Aurelia binding between component and sub-component not reflecting changes

我在主视图和自定义组件中都有文本输入。我希望它们的文本同步(更具体地说,从主组件 -> 子组件)。

这是我得到的:

app.html

<template>
  <require from="my-component"></require>
  Parent App Text: <input type="text" value.bind="mainAppText" />
  <br />
  <my-component myComponentText.bind="mainAppText"></my-component>
</template>

app.js

export class App {
  mainAppText;
}

my-component.html

<template>
  My Component Text: <input type="text" value.bind="myComponentText" />
</template>

my-component.js

import {bindable} from 'aurelia-framework';

export class MyComponent {
  @bindable myComponentText;
}

但是myComponentText不会更新。我错过了什么?

笨蛋:

http://plnkr.co/edit/infT53A3Y2aGbN9CR7B5?p=preview

尝试

<my-component myComponentText.two-way="mainAppText"></my-component>

我不确定这是否是规则,但我的经验是 'bind' 仅适用于 two-way 标准属性。

尝试在此处检查您的代码(不要对属性使用此类命名):http://plnkr.co/edit/qPkDqnLKa0I9nzJ0wTsc?p=preview

<my-component text.bind="mainAppText"></my-component>

@customElement('my-component')
export class MyComponent {
  @bindable
  text = '(default)';
}