I have a link, which when clicked, takes the user to a new page, but also, 
calls a method in the controller and passes a variable too.

So when I want to right click on it and open link in a new tab, I have 
created a directive for it:

module.directive('tabRightClick',['$parse', function($parse) {
    return function(scope, element, attrs) {
        var fn = $parse(attrs.tabRightClick);
        element.bind('contextmenu', function(event) {
            scope.$apply(function() {
                // event.preventDefault();
                fn(scope, {$event:event});
            });
        });
    };}]);


And in the .gsp file(I am using Grails) I have a table column that makes 
use of a bound variable 'trade':

<td class="nw" ng-click="setTradeId(trade.TradeId)" ng-class="{active: 
('account.trade.tradeDetails' | routeSegmentStartsWith)}">
                 <a href="#/account/trade/tradeDetails">{{trade.TradeId | 
limitTo : 8}}</a>
              </td>

But when I right click on the link and open it in new tab, the setTradeId 
method does not get called and my functionality fails completely.

Is there a way to fix this? Below is the method in my controller that I 
call:

$scope.setTradeId = function (tradeId) {
          tradesSharedService.setTradeIdOfTrade(tradeId);
      };

NOTE: I have provided the link to open in the .gsp file only, I haven't 
mentioned any routing in the controller method when the button is right 
clicked. 

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to