angular - Contents of file in angular2 -
i'm writing small app xml file aggregation. user drops xml files same structure, edits few common tags, , give them xml of needed data in list of elements.
i'm using ng2-file-upload file droping, can't figure out way contents of file. don't want upload file backend, read in contents , dom manipulation on xmls.
is possible send file angular2.0 route , have contents sent current component?
thanks @zero298's comment did more digging file api , came solution!
typescript using ng2-file-upload:
uploader: fileuploader = new fileuploader({}); //empty options avoid having target url reader: filereader = new filereader(); ngoninit() { this.reader.onload = (ev: any) => { console.log(ev.target.result); }; this.uploader.onafteraddingfile = (fileitem: any) => { this.reader.readastext(fileitem._file); }; }
just took digging ng2-file-upload code find how file object out of it.
Comments
Post a Comment