javascript - send variable from basic js to angular -


i want send variable in basic js angular in function. want send variable value1. seeing code declare value1 , after script closed want send value of value1 function doimportall declared in other file.

<script>       var value1='hi';       var openfile = function(event) {           var input = event.target;            var reader = new filereader();           reader.onload = function(){               var text = reader.result;               var node = document.getelementbyid('output');                 var lines = reader.result.split('\n');               for(var line = 0; line < lines.length; line++){                   console.log(lines[line]);               }               value1=lines[0];               node.innertext = lines[2]               document.getelementbyid('clicking').click();           };           reader.readastext(input.files[0]);       };   </script>   <button id="clicking"  class="btn btn-md" ng-click="doimportall(value1)" my-i18n="modal_importall"></button>   <div>       <input type='file' accept='text/plain' onchange="openfile(event)">   </div>   <div id='output'>       ...   </div> 

as pointed out, there's no reason not within angular service. if whatever reason wish have function not run inside angular, can assign value global window object so:

window.value1 = lines[0]; 

it accessible angular via window object. not elegant solution , should consider restructuring filereader logic work within angular.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -