我有一个非常简单的绑定,它没有像我期望的那样工作:
应用程序.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>
这将产生以下输出:
姓名:未知
姓名:未知
姓名:未知
姓名:未知
虽然我已经预料到:
姓名:约翰
姓名:埃里克
姓名:马丁
姓名:西蒙