【发布时间】:2017-01-26 22:15:09
【问题描述】:
在 ember index.html 我使用组件发送动作并获取文件
<script type="text/x-handlebars" id="components/picture-upload">
<input multiple="true" onchange={{action "upload"}}
accept="image/png,image/jpeg,application/pdf"
type="file"
/>
</script>
<script type="text/x-handlebars" id="upload">
{{picture-upload upload='upload'}}
{{outlet}}
</script>
在app.js
App.UploadController=Ember.Controller.extend({
actions:{
upload:function (event) {
//here to get file
}
}});
App.PictureUploadComponent=Ember.Component.extend({
actions:{
upload(){
//i want to send file but this is not good value
this.sendAction('upload',this);
}
}
});
但我不知道如何发送事件,我需要类似 answer 的东西,之后我想用 ajax 将文件发送到服务器,但问题是如何获取文件!
【问题讨论】:
标签: javascript ember.js handlebars.js