angularjs input file onchange error in jhipster webapp -
this question has answer here:
- ng-model <input type=“file”/> 10 answers
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
Post a Comment