When using AngularJS to add a row to an HTML table by clicking an "Add row" button and using $scope.photos.push({}), you may encounter an issue when trying to trigger the file dialog of the new row's file input field. Is it possible to do this and if so, how?
.controller('mainController', function ($scope) {
$scope.photos = [];
$scope.addPhoto = function(){
$scope.photos.push({});
document.getElementById("photo" + $scope.photos.length-1).click(); // this won't work because the element is not yet rendered.
}
});
HTML
<tr ng-repeat="photo in photos">
<td> <input type="file" id="photo{{ $index }}"> </td>
</tr>