Commit 4fa4c275 by Erik Sundell Committed by Daniel Lee

Upload: Fixing link function in directive

parent ef3beb1f
import coreModule from 'app/core/core_module';
const template = `
<input type="file" id="dashupload" name="dashupload" class="hide"/>
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
<label class="btn btn-success" for="dashupload">
<i class="fa fa-upload"></i>
Upload .json File
......@@ -16,7 +16,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
scope: {
onUpload: '&',
},
link: scope => {
link: (scope, elem) => {
function file_selected(evt) {
const files = evt.target.files; // FileList object
const readerOnload = () => {
......@@ -52,7 +52,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
// Check for the various File API support.
if (wnd.File && wnd.FileReader && wnd.FileList && wnd.Blob) {
// Something
document.getElementById('dashupload').addEventListener('change', file_selected, false);
elem[0].addEventListener('change', file_selected, false);
} else {
alertSrv.set('Oops', 'Sorry, the HTML5 File APIs are not fully supported in this browser.', 'error');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment