Javascript Aurelia绑定重复。不工作

Javascript Aurelia绑定重复。不工作,javascript,aurelia,Javascript,Aurelia,我试图在repeat.for中为aurelia组件设置一个可绑定的值,它似乎没有任何影响 <event-summary repeat.for="event of events" event.bind="event" is-favorite="true"></event-summary> 事件设置正确,但无论我尝试什么,isFavorite始终未定义(is favorite.bind=“[some vm value]”)也返回未定义。谁能告诉我为什么 谢谢我从未使用过bi

我试图在repeat.for中为aurelia组件设置一个可绑定的值,它似乎没有任何影响

<event-summary repeat.for="event of events" event.bind="event" is-favorite="true"></event-summary>
事件设置正确,但无论我尝试什么,isFavorite始终未定义(is favorite.bind=“[some vm value]”)也返回未定义。谁能告诉我为什么


谢谢

我从未使用过
bind()
函数,但通常您的作用域上有
isFavorite
,比如
this.isFavorite
。您还可以在构造函数中执行空检查

这对我有用:

从'aurelia framework'导入{bindable};
导出类测试元素{
@可装订物品
@我最喜欢装订
构造函数(){
console.log(this.isFavorite);
console.log(此.item);
}
绑定(bindingContext,overrideContext){
console.log(“bc”,bindingContext);//此处未定义项或isFavorite
console.log(“oc”,overrideContext);//此处未定义项或isFavorite
}
}
最受欢迎。bind=“true”
应该可以
is favorite=“true”
也应该可以工作,尽管在这种情况下,isFavorite bindable属性将被分配字符串
'true'
。以下是这两方面的一个可运行示例:

所以它可以工作,但是为什么bindingContext不包含.isFavorite?它在我当前的作用域上,只是混淆了为什么它不在绑定上下文上?标记作为答案,但我混淆了为什么isFavorite不在我的绑定上下文上,但它在我的本地作用域上。
@bindable('isFavorite')
@bindable('event')
export class EventSummary {
    bind(bindingContext) {
        if(bindingContext.isFavorite == null) {
            this.isFavorite = false;
        }
    }
}
import {bindable} from 'aurelia-framework';

export class Testelement {

    @bindable item
    @bindable isFavorite
    constructor() {
        console.log(this.isFavorite);
        console.log(this.item);
    }

    bind(bindingContext, overrideContext) {
        console.log("bc ", bindingContext); //no item or isFavorite defined here
        console.log("oc ", overrideContext);//no item or isFavorite defined here
    }
}


<testelement item.bind="element" repeat.for="element of data" is-favorite="true"></testelement>