This is a migrated thread and some comments may be shown as answers.

Angular JS: display files previously loaded + make the files downloadable

5 Answers 237 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Labhesh
Top achievements
Rank 1
Labhesh asked on 18 Oct 2016, 10:41 PM

Hi, I am using the upload widget with angular. 

I am looking for it to achieve the following:

1) have something like k-files = "initialFiles" in the input options; to display list of previously loaded files. 

I tried using k-files along with in javascript code; but that does not work.. how do I make this feature work? 

2) Is there a way to use template (again using angular) to make the previously uploaded files downloadable? I saw a similar post but it had no examples. Can you give a small example on how to do this? 

Thanks

$scope.initalFiles = [ { name:"test1.txt" }, {name: "test2.txt" } ];
<p><input name="files"<br>    id="files"<br>    type="file"<br>    kendo-upload="uploader"<br>    k-select="onSelect"<br>    k-success="onSuccess"</p><p>k-files = "initialFiles"</p><p>    k-async="asyncOptions"/></p>

5 Answers, 1 is accepted

Sort by
0
Labhesh
Top achievements
Rank 1
answered on 18 Oct 2016, 11:06 PM

I've got the #1 above to work using k-options...but I still need help with enabling the files to be downloaded

 

$scope.uploadOptions = {<br>    async : {<br>        saveUrl: baseURL+"upload",<br>        removeUrl: baseURL+"remove",<br>        autoUpload: true<br>    },<br>    files : $scope.initialFiles<br>};
0
Labhesh
Top achievements
Rank 1
answered on 18 Oct 2016, 11:07 PM

I've gotten #1 to work, but I still need help with downloading the uploaded files

 

$scope.uploadOptions = {async : {saveUrl: baseURL+"upload",removeUrl: baseURL+"remove",autoUpload: true},files : $scope.initialFiles};

 

0
Dimiter Madjarov
Telerik team
answered on 19 Oct 2016, 06:41 AM

Hello Labhesh,

Yes, the Upload widget supports displaying the files in the list via template. Here is a sample approach to achieve this.

Regards,
Dimiter Madjarov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Labhesh
Top achievements
Rank 1
answered on 19 Oct 2016, 03:15 PM

Thanks - Dimiter; 

Is there a way to write templates in the script that contains the angular code?

To be specific ; can this line be moved into the angular script? The reason is I'd like to form the download dynamically where host is based on whether one is in testing or production

    <script id="fileTemplate" type="text/x-kendo-template"><br>       <a href="<downloadUrl>">#= name #</a><br>      <button type='button' class='k-upload-action'></button><br>    </script>

 

0
Dimiter Madjarov
Telerik team
answered on 20 Oct 2016, 08:05 AM

Hello Labhesh,

Yes, you could build the template in the controller and don't rely on an external script tag element. The template property itself could be set to a string or a function:

http://docs.telerik.com/kendo-ui/api/javascript/ui/upload#configuration-template

For convenience I modified the example.

Regards,
Dimiter Madjarov
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
Tags
Upload
Asked by
Labhesh
Top achievements
Rank 1
Answers by
Labhesh
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or