Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is a code which I'm currently using to open a custom window on click of a button:
The problem is how to write the same code in angularJS controller so that I donot have to bind the angular part to id of anchor tag and then pass it in on click as this.id ? If I try to pass directly in onclick it throws error that it is not allowed(which is correct as it cannot).

What I have tried:

<a id="{{d.applicantDocumentId}}" href="#" onclick="openAttachment(this.id)"></a>





function openAttachment(id)
  {
       var w = window.innerWidth;
          var h = window.innerHeight;
          window.open('@Url.Action("DocumentViewer", "Profile")' + "?docId=" + id, '_blank', 'left=' + w / 5 + ',top=' + h / 5 + ',width=' + (w / 5) * 3 + ',height=' + (h / 4) * 3 + ',toolbar=1,resizable=1');

  }
Posted
Updated 26-Jul-18 0:20am

1 solution

$scope.openAttachment = function(id) {
           var w = window.innerWidth;
           var h = window.innerHeight;
           $window.open(' ~/Controller/Actionresult?docId='+id, '_blank', 'left=' + w / 5 + ',top=' + h / 5 + ',width=' + (w / 5) * 3 + ',height=' + (h / 4) * 3 + ',toolbar=1,resizable=1');
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900