2017-01-26 1 views
0

In ember index.html i Komponente Aktion zu senden verwenden und DateiDatei senden an Ember Controller

<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> 

und in 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); 
    } 
    } 
}); 

zu bekommen, aber ich weiß nicht, wie Ereignis zu senden, ich brauche etwas wie das answer, danach möchte ich mit ajax Datei an den Server senden, aber das Problem ist, wie man Datei!

Antwort

0

In PictureUploadComponent

upload(event){ 
     //i want to send file but this is not good value 
     this.sendAction('upload',event); 
    } 
Verwandte Themen