Using Cookie value from one ng-app in another ng-app in AngularJS
<p>I know that it isn't good practice to have multiple ng-apps in a project but my project is divided into segments that aren't generally related to each other, plus I am left with more or less no other option.</p>

<p>My problem is the persistence of <code>ng-cookie</code> amidst two separate Javascript files. Let's say I have <code>dashboard1.html</code> that is linked to <code>controller1.js</code> and <code>dashboard2.html</code> linked to <code>controller2.js</code>.</p>

<p>Now, I want to access the cookie value of controller 1 in controller 2. When I try to do this the result says undefined and that means I cannot access the cookie value set by another Javascript file.</p>

<p>Please advise me how to solve this issue.</p>

<p>NOTE : Javascript files have respective ng-app defined and controller for each application. </p>

<p>This is Controller and <code>ng-app</code> part of one module. </p>

<pre><code>var app = angular.module('mainpageapp', ['ngRoute','ngCookies']);
    app.controller('ctrlmainpage', ['$scope', '$timeout','$http', '$route', '$routeParams', '$location', '$rootScope', '$cookies', function ($scope, $timeout, $http, $route, $routeParams, $location, $rootScope, $cookies) {
        console.log("Csadad");

        $cookies.myFavorite = 'TestCookie';
        var favoriteCookie = $cookies.myFavorite;
        console.log("Cookie" + favoriteCookie);
</code></pre>

<p>Now in this ng-app's controller I am setting a cookie, it works properly and I do get expected response on console. This is in file controller1.js</p>

<p>Now I am trying to access the same cookie in controller2.js that is all together bound by different ng-app. </p>

<pre><code>var app = angular.module('myApp', ['ngRoute', 'smart-table', 'ngCookies']);
var id = 'hasdh';
app.controller('dashmerctrl', ['$scope', '$timeout','$http', '$route', '$routeParams', '$location', '$rootScope', '$cookies', function ($scope, $timeout, $http, $route, $routeParams, $location, $rootScope, $cookies)
{
    var favoriteCookie1 = $cookies.myFavorite;
    console.log("Cookie1" + favoriteCookie1); 
</code></pre>

<p>Her I get undefined as output. </p>

<p>I want to access that same cookie in this file. </p>