Haskell Fun Haskell Fun - 3 years ago 88
AngularJS Question

Closing ng-href - cross button or auto closing after downloading file

I dynamically show message with link to download some file (it does work):

<a ng-href = "{{myCtrl.fileUrl}}" download = "{{myCtrl.file}}">
{{myCtrl.file}}
</a>


How to close (or even better - add cross in right up corner) this message ?

Answer Source

Follow these steps :

 1. Add ng-hide directive to your anchor tag. Example ng-hide="hideLink"
 2. Call a function on click of download link. Example ng-click="downloadLinkClicked()"
 3. Within the function, set $scope.hideLink = true;
 4. Your download link will be hidden now.

Code snippet :

In you HTML

<a ng-href = "{{myCtrl.fileUrl}}" download = "{{myCtrl.file}}" ng-hide="hideLink" ng-click="downloadLinkClicked()">
    {{myCtrl.file}}
</a>

In your js controller :

$scope.hideLink = false;
    $scope.downloadLinkClicked = function () {
        $scope.hideLink = true;
    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download