Search Posts

Category: filereader

How do I read a JSON file in Angular?

I am trying to load a JSON file from local disk and use the data from it to fill a FabricJS canvas. I have problems on getting the data from the file. This is what i have till now. app.html <input type=”file” accept=”.json” id=”fileInput” (change)=”loadFile($event)”/> app.ts loadFile(event) { const eventObj: MSInputMethodContext = <MSInputMethodContext> event; const target: HTMLInputElement = <HTMLInputElement> eventObj.target; const files: FileList = target.files; this.file = files[0]; const reader = new FileReader(); reader.readAsText(this.file, ‘utf8’); […]

How to Use Variable as location url?

Hello guys How to replace the location of file URL into variable? NgMap.getMap().then(function (map) { $scope.map = map; var myParser = new geoXML3.parser({ map: map }); myParser.parse(‘cta.kml’); }); myParser.parse is only accepting url but not variable? is this possible? var result = “<?xml version=”1.0″ encoding=”UTF-8″?> <kml xmlns=”http://earth.google.com/kml/2.1”> <!– Data derived from: Ed Knittel – || tastypopsicle.com Feel free to use this file for your own purposes. Just leave the comments and credits when doing so. […]