【发布时间】:2017-11-07 12:19:18
【问题描述】:
我正在使用这个包 https://github.com/tim-evans/ember-file-upload
在他们的示例中,他们调用路由操作来上传图片
onfileadd=(route-action "uploadImage")}}
但是我想改为调用组件操作
我试过了
onfileadd="uploadImage"}}
并在组件中添加动作:
uploadImage: function (file) {
console.log(file);
let self = this;
RSVP.cast(Ember.$.get(ENV.APP.API_HOST + "/v1/teams/signed_url/")).then(function (response) {
return file.upload(response.url, {
data: response.credentials
});
}).then(function (response) {
self.set('url', response.headers.Location);
});
},
但我得到了错误:
未捕获的类型错误:无法读取未定义的属性“uploadImage”
如果我将其移动到路由,该操作将按预期工作,但我需要更新组件中的正确属性(路由中不存在)
知道我可以做些什么来将其更改为组件功能吗?
【问题讨论】:
标签: javascript ember.js