I am currently having an anchor tag defined like
<a href="" ng-click="controllerFn(scopeVar)">Click here</a>
Inside the controller function, I am using ng-storage ($localStorage to set some values, and then using angular-ui router to go to next state. New link will open in a new tab.
$scope.controllerFn = function(var){
$localStorage.headings = $localStorage.headings || {};
$localStorage.headings[var.uuid] = var;
var url = $state.href('newstate', {id: var.uuid, name : var.name});
window.open(url,'_blank');
};
This works as expected.
But, when user right clicks on the anchor tag and selects open in new tab, it doesn't work and user is taken to the main landing page and not to the new route.
When user selects open in new tab, I would like to call "controllerFn" so that $localStorage values are set before going to new state and link should open in new tab.
Is that possible? any ideas?