usman usman - 1 month ago 9
AngularJS Question

AngularJS ng-click functions not working after I open print dialog

Here is very strange kind of error I am facing, I have a function which actually hides a div works fine if I don't open the print dialog, I have requirement to give print functionality for some data, but if I open the print dialog then the ng-click function is not working any more nothing happens and neither the browser shows any error in console. This is happening to all of my functions present on this page.

Here is my html code:

<button type="button" class="btn btn-sm btn-danger" title="Cancel Preview" ng-click="cancelPreview()">
Cancel
</button>


and this is my AngularJS controller code:

$scope.cancelPreview = function() {
$scope.showInvoice = false;
}

Answer

@usman check it out my jsfiddle based on yours jsfiddle I used $compile.

document.body.innerHTML = "";
var element = $compile(originalContents)($scope);
angular.element(document.body).append(element);
Comments