I dont know if this is the "correct" way to do this but solves my problem.
I changed the URLs to have that variable using $routeParams. Now, in the 
later controller I say:

var loc = $location.url();
$scope.query_param_using_which_ajax_call_is_made = loc.split('/')[2];

and then I got ahead with ajax call.
Since, the url doesn't change with page refresh and new tab will always 
have that right url, my application is pointing to the correct ajax calls.

If any other sleek way to solve this problem is available, please let me 
know.

Thank you.

On Wednesday, May 21, 2014 7:54:58 AM UTC-7, Eric Eslinger wrote:
>
> yeah, chrome at least sets window.opener on o-i-n-t windows to the parent 
> tab. Just realized I could test this just in the devtools without mucking 
> around with messageEvents - you just need to check if window.opener is null 
> or not.
>
> e
>
>
> On Wed, May 21, 2014 at 7:49 AM, Eric Eslinger 
> <[email protected]<javascript:>
> > wrote:
>
>> As far as I know, the browser treats each window as a separate memory 
>> space (so shared objects are right out) and each reload/refresh event as a 
>> total restart. You could try being clever with localStorage (although 
>> rapid-fire clicks would probably lead to a race condition as you can't 
>> really guarantee instantiation order of the tabs, I imagine). 
>>
>> It would also be helpful to store all relevant variables in your path, 
>> but if that's not available, you may need to look into using some kind of 
>> cross-window communication. I *think* (I've never actually tried this) that 
>> a tab opened via open-in-new-tab maintains a reference to the parent window 
>> in window.opener, so could get get clever with all kinds of message events.
>>
>> Best bet is storing unreconstructable state in the URL, I think. That 
>> seems to me like what it's for.
>>
>> e
>>
>>
>> On Wed, May 21, 2014 at 6:56 AM, Srikar Shastry 
>> <[email protected]<javascript:>
>> > wrote:
>>
>>> Hello,
>>> I have two pages each supported by respective controllers. Now, I want 
>>> to pass variable from first controller to another as later utilizes it as 
>>> get query parameter (not the path parameter). I tried services but when 
>>> user right clicks and clicks "open link in a new tab", the second 
>>> controller receives am empty var. Same happens when user reloads the page. 
>>> I tried  local storage but the problem with that is when user tries to open 
>>> multiple links, all point to the latest variable(true since local storage 
>>> is being overwritten with latest vars as user clicks on links). Any idea on 
>>> how to restrict services from reseting on page reload?
>>>
>>> --
>>> 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] <javascript:>.
>>> To post to this group, send email to [email protected]<javascript:>
>>> .
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
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