我有一个非常简单的绑定,它不像我期望的那样工作:
app.js:
export class PupilsViewer {
pupilsInfo = [
{ name: 'John' },
{ name: 'Eric' },
{ name: 'Martin' },
{ name: 'Simon' }
];
}app.html:
<template>
<require from="./pupil"></require>
<pupil repeat.for="pupilInfo of pupilsInfo" info="${pupilInfo}"></pupil>
</template>pupil.js:
import {bindable} from 'aurelia-framework';
export class Pupil {
@bindable info = { name: 'unknown' };
}pupil.html:
<template>
<div>Name: ${info.name}</div>
</template>这将产生以下结果:
姓名:不详 姓名:不详 姓名:不详 姓名:不详
虽然我预料到:
姓名:约翰 姓名: Eric 姓名: Martin 姓名: Simon
发布于 2015-04-30 11:03:24
现在我也有同样的问题。这似乎是个错误问题。试着改变或移除你的手提箱骆驼箱。但你的装订也不太好。
export class PupilsViewer {
pupils = [
{ name: 'John' },
{ name: 'Eric' },
{ name: 'Martin' },
{ name: 'Simon' }
];
}app.html
<template>
<require from="./pupil"></require>
<pupil repeat.for="pupil of pupils" info.bind="pupil"></pupil>
</template>pupil.js
import {customElement, bindable} from 'aurelia-framework';
@customElement('pupil')
@bindable('info')
export class Pupil {
}https://stackoverflow.com/questions/29963074
复制相似问题