sending data to another app modul (another page) using a dblclick function in angularjs

83 views Asked by At

I have two pages in my angularjs application, I get some data from database to show in a table, then i doubleclick on a row and go to another page to show more details. The problem consists on how to send data from the first page to the second one to show them knowing that i have all the data i need to show in my variable "branchs" that i showed some of them in the first page, here is a part of my code :

var app= angular.module('MyApp' , []);
app.controller('Ctrl', function($scope, $http){
     $http.get('http://localhost:8080/Test_WS/test/branchs/brnch')
     .then(function(response) {
         $scope.branchs = response.data;

     })

     .then(function(response) {
     $scope.details = function (b) {
        window.location = 'http://localhost:8080/TestProject/CreateBranch.html'; 
     };
     });
});
1

There are 1 answers

4
Sachila Ranawaka On

Since you have the data in a variable i recommend to create an factory. In the first page create new factory method and save data in a varible using a factory method. Once you navigate to second page call another factory method which return the data

Another way you can do this using rootscope. But i would not recommend this because as the application get extend code will get confused and it will be overhead to the memory