How to extend angular -decutable editable line with file upload field

I am trying to expand (my real example is very similar) angular -xeditable - Editable string example - the example described here: http://vitalets.imtqy.com/angular-xeditable/#editable-row or its jsFiddle link here: http: / /jsfiddle.net/NfPcH/93/

so I have another column to upload the file for each row / element. It is normal if it can only be an input element of a file of type, but I am open to other solutions. Usually my column looks like this:

<td> <span editable-text="template.description" e-name="description" e-form="rowform" e-required> {{ template.description || 'empty' }} </span> </td> 

But now I want to add my custom column, and I tried the input element with or without all metioned attributes here:

  <td> <input id="file" accept="application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ng-show="rowform.$visible" class="btn btn-default" name="file" type="file" e-name="file" e-form="rowform" value="{{ user.file || 'empty' }}" /> </td> 

In any case, I cannot get the value file in my angular controller after trying to save the line when this code is executed:

  $scope.saveUser = function (data, id) { //$scope.user not updated yet angular.extend(data, { id: id }); angular.extend(data, { file: file }); return $http.post('/saveUser', data); }; 

My - data is an object here with all other properties, such as - description - but not with - file - property!

Of course, I expanded the onbeforesave form with:

... form editable-form name = "rowform" onbeforesave = "saveTemplate ($ data, user.id, user.file)" ...

Any suggestion?

Thank you Vedran

+6
source share
1 answer

I am stuck in this.

When I thought that everything was fine, because I got the file object in my angular model, using the solution with the creation of the custom directive mentioned here:

ng-model for <input type = "file" />

... then a new question began to bother me.

I cannot get this file object displayed during the binding process to the HttpPostedFileBase parameter of the MVC.

I tried everything, for example, by excluding the property and adding a separate parameter to my MVC controller or creating a custom MVC middleware, but the examples I saw used the ModelBinderResult class that I could not find in MVC 5 classes in any namespace.

This File object is for sure here, but I couldn't get it to work. I know that the object is not empty or empty, because if I specify the type of the input parameter of the controller => the object, then it is not null.

Please any help would be more than welcome!

Vedran

0
source

Source: https://habr.com/ru/post/988393/


All Articles