1

I have a problem. I have textbox where i need to enter a pin and button for submit, and when user click on button i get popupt that contains data for that pin. When user click on that button it display url something like this :

http://localhost:60664/#?ticketid=87879578 

Now i need to handle function when i open in another window that link to be able to see that popup. How can i do that?

This is my function that works on click:

$scope.ShowDetails = function (pin) {
    if ($scope.showdetail == false && pin != null) {
        $scope.pin = pin;


        $http.get(Url + 'Get/' + $scope.pin)
            .success(function(data, status, headers, config) 
            {
               $("#background").addClass("darker");
                $scope.showdetail = true;
                $scope.NotFound = false;
                $location.search('pinid', pinTicket);


            })
            .error(function(data, status, headers, config) {

                $scope.NotFound = true;
                $scope.showdetail = false;



        })
       .then(Details, ErrorResponse);

    }

}
None
  • 8,817
  • 26
  • 96
  • 171

2 Answers2

0
$location.search().ticketid

should do the trick

so if you want to check if the url has an id, and if it has, run a function

if($location.search().ticketid) {
  myFunction($location.search().ticketid);
}
rmuller
  • 1,837
  • 12
  • 12
0
//this should provide you the params
var urlParams= $location.search(); 

//in your case, urlParams would be {ticketid: '87879578'}
//access ticketid as
var ticketId = urlParams['ticketid'] // or as $location.search().ticketid.

if(ticketId){
    // do something here
}
//if u want it to set to a different value sometime later, use following,
$location.search('ticketid', '12548585');
Sudhansu Choudhary
  • 3,322
  • 3
  • 19
  • 30