-1

I want to redirect and pass some data to other page.But not using query string and not pass data in URL

(function() {
var app = angular.module('PlateformApp', [])


    app.controller('PlateformController', function ($scope,$window) {
        //This will hide the DIV by default.
        $scope.IsVisible = false;
        $scope.ShowHide = function (platform) {
            //If DIV is visible it will be hidden and vice versa.
            $scope.IsVisible = $scope.IsVisible ? true : true;
            //alert(platform);
            document.getElementById("platform").value = platform;
            var myEl = angular.element( document.querySelector( '#plat_val' ) );
            myEl.text(platform); 
        }

        $scope.storeAppWindow = function()
        {

            //store_url = $scope.storeUrl;
            test_bc_url = ""
            text_sh_url = ""
            platform_val = document.getElementById("platform").value;

            $http.get("/user/installedapp")
              .then(function(response) {
                  $scope.myWelcome = response.data;
            });

            if (platform_val == "BC")
                $window.open(test_bc_url,  "popup", "width=500,height=400,left=10,top=50");
            else if (platform_val == "Sh")
                $window.open(text_sh_url,  "popup", "width=500,height=400,left=10,top=50");

        }
    });

})();

Here It will open new window but i want to pass platform_val text_sh_url url in another page.And i am using flask in python.

Piyush
  • 511
  • 4
  • 13

1 Answers1

0

You can pass the data by various methods, using $stateParams,using Storages, using factories or services. You can find the example using storage in my answer in this thread: sharing data using storages

(function() {
  var app = angular.module('PlateformApp', [])
  app.factory('newService', function() {
    function set(data) {
      datatosend = data;
    }

    function get() {
      return datatosend;
    }

    return {
      set: set,
      get: get
    }
  });
  app.controller('PlateformController', function($scope, $window, newService) {
    //This will hide the DIV by default.
    $scope.IsVisible = false;
    $scope.ShowHide = function(platform) {
      //If DIV is visible it will be hidden and vice versa.
      $scope.IsVisible = $scope.IsVisible ? true : true;
      //alert(platform);
      document.getElementById("platform").value = platform;
      var myEl = angular.element(document.querySelector('#plat_val'));
      myEl.text(platform);
    }

    $scope.storeAppWindow = function()
    {

      //store_url = $scope.storeUrl;
      test_bc_url = ""
      text_sh_url = ""
      platform_val = document.getElementById("platform").value;

      $http.get("/user/installedapp")
        .then(function(response) {
          $scope.myWelcome = response.data;
        });

      if (platform_val == "BC") {
        $window.open(test_bc_url, "popup", "width=500,height=400,left=10,top=50");
      }
      else if (platform_val == "Sh") {
        var data = {
          'platform_val': platform_val,
          'text_sh_url ': text_sh_url
        };
        newService.set(data);
        $window.open(text_sh_url, "popup", "width=500,height=400,left=10,top=50");
      }

    }
  });

})();

And,in the page where you want to get the data. Just inject newService in the controller of that page and use newService.get(data)

app.controller('pageController',function($scope,newService){
   var datafromanothercontroller = newService.get(data); 
   console.log(datafromanothercontroller );
})
Community
  • 1
  • 1
Sunil Lama
  • 4,531
  • 1
  • 18
  • 46