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

5
  • Is it just passing the data to another controller in angularjs?? Commented Nov 23, 2016 at 4:08
  • I want to send data to other page Commented Nov 23, 2016 at 10:18
  • that just means that you need to pass the data to the controller of that particular page which you can do using localstorage or by creating service. Commented Nov 23, 2016 at 10:31
  • If it is possible can you give me example of how to create Service . Commented Nov 24, 2016 at 10:59
  • sorry for the late answer @piyush, it was really easy, so i thought you might have figured that out. anyway i have answered below, hope that helps you Commented Nov 25, 2016 at 7:02

1 Answer 1

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 );
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.