here is the view in jade
:
button#save-csv-btn(ng-click="click()") Export CSV
input#save-csv(style="display:none", type="file", onchange="angular.element(this).scope().saveCSVFileChanged(this)")
js:
$scope.click = ->
# $('#save-csv').trigger('click')
Error I get:
Error: $apply already in progress
The syntax is the following: function clickOnUpload() { $timeout(function() { angular. element('#myselector'). triggerHandler('click'); }); }; // Using Angular Extend angular.
I changed $scope.click
function to trigger the input click in a setTimeout
. This lets the first $apply
finish, and then will trigger another one.
$scope.click = function() {
setTimeout(function() {
inputEl.click();
}, 0);
}
Note that I use setTimeout
, not $timeout
. $timeout
would also be inside an $apply
block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With