1

我有一个非常简单的绑定,它没有像我期望的那样工作:

应用程序.js:

export class PupilsViewer {

    pupilsInfo = [
        { name: 'John' },
        { name: 'Eric' },
        { name: 'Martin' },
        { name: 'Simon' }
    ];

}

应用程序.html:

<template>
    <require from="./pupil"></require>
    <pupil repeat.for="pupilInfo of pupilsInfo" info="${pupilInfo}"></pupil>
</template>

学生.js:

import {bindable} from 'aurelia-framework';

export class Pupil {
    @bindable info = { name: 'unknown' };
}

学生.html:

<template>
    <div>Name: ${info.name}</div>
</template>

这将产生以下输出:

姓名:未知
姓名:未知
姓名:未知
姓名:未知

虽然我已经预料到:

姓名:约翰
姓名:埃里克
姓名:马丁
姓名:西蒙

4

1 回答 1

2

现在我有同样的问题。这似乎是一个错字问题。尝试更改或删除可绑定项的驼峰式案例。但你的绑定也不行。

export class PupilsViewer {

    pupils = [
        { name: 'John' },
        { name: 'Eric' },
        { name: 'Martin' },
        { name: 'Simon' }
    ];

}

应用程序.html

<template>
    <require from="./pupil"></require>
    <pupil repeat.for="pupil of pupils" info.bind="pupil"></pupil>
</template>

瞳孔.js

import {customElement, bindable} from 'aurelia-framework';

@customElement('pupil')
@bindable('info')
export class Pupil {

}
于 2015-04-30T11:03:24.233 回答