1
<input type="file"  accept="image/*" ng-model="imageupload" /> 

My problem is, I want to call a function when the user will browse an image file then a function will trigger.

The value of the ng-model of the input type file is going to change. Then a function will call, that function will upload the image to a folder.

That has to implement in AngularJS

Mihail Duchev
  • 4,691
  • 10
  • 25
  • 32
  • I can't understand the question bro, can you give me more explanation. – Nadeem Khoury Dec 18 '15 at 14:42
  • Possible duplicate of [AngularJs: How to check for changes in file input fields?](http://stackoverflow.com/questions/17922557/angularjs-how-to-check-for-changes-in-file-input-fields) – yoogeeks Dec 18 '15 at 14:59

2 Answers2

2

You should look at ng-change directive of input field

ngChange

Evaluate the given expression when the user changes the input.

Example

HTML:

<body ng-controller="mainCtrl">
  <input ng-model='imageUri' type='text' ng-change='alert()'/>
</body>

Angular code:

app.controller('mainCtrl', function($scope){
    $scope.alert = function(){
      alert('hello');
    }
});
yoogeeks
  • 965
  • 8
  • 24
1

Consider u have a html element with type as file,now add an ng-change directive to that element.

<input type="file" ng-change="trigger()">

Now in your js refer the code as below

var app=angular.module('app',[]);
app.controller('MyCtrl',function($scope){
$scope.trigger=function(){
//your code to copy a file to folder
}
});
bhanu.cs
  • 1,345
  • 1
  • 11
  • 25