Home Ask Login Register

Developers Planet

Your answer is one click away!

ganesh February 2016

Index not working in angular JS

Im trying to get values for onchange in fileupload to use in controller.

  <span id="ind">{{$index}}</span>
  <input id="PhotoPicker" type="file" accept="image/*" capture="camera" title="{{JobDetail.Id}}" alt="{{$index}}" onchange="angular.element(this).scope().file_changed(this)" /></div>

Here,In the span ind i cant able to get the row index. When i use it in alt its not working. I can able to get the title too. In alt it always shows zero.

 $scope.file_changed = function (element) {

    var filesSelected = element.files;
    var JobDetailId = element.title; //working
    var index = element.alt; //not working

Kindly help me!


Walfrat February 2016

My guess is that angular will only give you the files attribute because your input is of type file. You should use angular.attr() for others attribute, see https://docs.angularjs.org/api/ng/function/angular.element

By the way i think this :


Can be rewritten to :


You might consider using this module : https://github.com/danialfarid/ng-file-upload

Post Status

Asked in February 2016
Viewed 3,300 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life