Hello so I kinda got thrust into the middle of EmberJS. I have worked a few tutorials but I am still struggling with something I feel like should be super simple. I am trying to add a delete row button for my table. Eveything is rendering correctly I just don’t think I am handling my Data correctly.
{{#each model as |file|}}
<tr>
<td>{{file.name}}</td>
<td>{{file.size}} MB</td>
<td>{{file.type}}</td>
<td><button type="button" class="btn btn-outline-danger btn-sm" {{action 'removeFile'}}>Delete</button></td>
</tr>
{{/each}}
//routes/import.js
import {A} from '@ember/array';
import Route from '@ember/routing/route';
export default class ImportRoute extends Route {
model() {
return A();
}
}
I am able to get the files that are being imported via a drag and drop box into my model and I can remove the files from the model as well but I guess my true issue is the Table does not update upon deleting a file.
//controllers/import.js
async removeFile(){
let files = this.model;
let fileNames = [];
for(let i=0; i<files.length; i++){
fileNames.push(files[i].name);
}
if(files[0].name == fileNames[0]){
files.splice(0, 1)
}
},
This is how I am removing said file and yes it is obviously only going to work for the first file rn I can work on that logic after but can anyone assist me please and thank you a ton in advance.