Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-click doesn't open new windows

I have a table in which the last column contains buttons that should open a new window but they don't. Here is my code:

<table class="table  table-hover" id="angular_table">
  <thead>
    <tr>
      <th class="company">Nome azienda&nbsp;<a ng-click="sort_by('company')"><i class="icon-sort"></i></a></th>
      <th class="code">Codice&nbsp;<a ng-click="sort_by('code')"><i class="icon-sort"></i></a></th>
      <th class="projectName">Nome progetto&nbsp;<a ng-click="sort_by('projectName')"><i class="icon-sort"></i></a></th>
      <th class="recordType">Tipo di record&nbsp;<a ng-click="sort_by('recordType')"><i class="icon-sort"></i></a></th>                            
      <th class="year">Anno&nbsp;<a ng-click="sort_by('year')"><i class="icon-sort"></i></a></th>
      <th class="month">Mese&nbsp;<a ng-click="sort_by('month')"><i class="icon-sort"></i></a></th>
      <th>Crea ricavo&nbsp;</th>
    </tr>
  </thead>                        
  <tbody>
    <tr ng-repeat="item in items | filter:query:checkEqual | orderBy:sortingOrder:reverse " id="lista">
      <td>{{item.company}}</td>
      <td >{{item.code}}</td>
      <td style="text-align: -webkit-left;"> <a href="/{{item.id}}" target="_blank">{{item.projectName}}</a></td>
      <td>{{item.recordType}}</td>                            
      <td>{{item.year}}</td>
      <td>{{item.month}}</td>
      <td class="btnCrea"><button class="btn2 btn-default2" ng-click="window.open('/apex/creaRicavoM?id={{item.id}}','_blank','heigth=600,width=600')">Crea</button></td>
    </tr>
  </tbody>
</table>

Can someone help me? Thanks in advance!

like image 418
DarkSkull Avatar asked Jan 08 '23 05:01

DarkSkull


1 Answers

Please define the function into $scope or $rootScope, and call that function on ng-click.

Example :

in $scope

$scope.openurl = function(url){
    window.open(url, '_blank','heigth=600,width=600');   // may alse try $window
} 

Or

in $rootScope

 $rootScope.openurl = function(url){
        window.open(url, '_blank','heigth=600,width=600');   // may alse try $window
    } 

In html, Try this

 <td class="btnCrea"><button class="btn2 btn-default2" ng-click="openurl('/apex/creaRicavoM?id={{item.id}}')">Crea</button></td>
like image 128
rajeshpanwar Avatar answered Jan 10 '23 19:01

rajeshpanwar