angularjs input file onchange error in jhipster webapp -


this question has answer here:

angularjs v1.5.8

<input type="file"   onchange="angular.element(this).scope().uploadimage()" />  $scope.uploadimage = function(){             alert("change");         } 

error in console:

uncaught typeerror: cannot read property 'uploadimage' of undefined @ htmlinputelement.onchange

i think have setup angular wrong, should work this:-

var app = angular.module("myapp", []);  app.controller("myctrl", function($scope) {      $scope.uploadimage = function() {      alert("change");    }  });
<!doctype html>  <html>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>    <body>      <div ng-app="myapp" ng-controller="myctrl">        <input type="file" onchange="angular.element(this).scope().uploadimage()" />      </div>


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -