0

I need to pass the parameter id in a URL using ng-click in Angularjs, I am doing this because of I want to view a specific user subdocument data in a separate page.

<tr ng-repeat="register in registerlist | filter:searchText">
  <td>{{$index+1}}</td>
  <td>{{register.name}}</td>
  <td>{{register.email}}</td>
  <td>{{register.mobile_no}}</td>
  <td>{{register.area_name}}</td>
  <td>
    <button type="button" class="btn btn-default"
            ng-click="RegisterView(register._id); showOrder = !showOrder">View</button>
  </td>
</tr>

URL example: localhost:8080//register/5426ced88b49d2e402402205

Here this above user had subdocument, so i need to view the subdocument in a separate page.

Controller:

$scope.RegisterView = function(id) {
  $scope.IsVisible = $scope.IsVisible ? false : true;
  $http.get('/auth/register-list/' + id).success(function(response){
    $scope.bookinglist = response.booking;
  });
};
Nodemon
  • 1,036
  • 2
  • 25
  • 47

2 Answers2

1

You can use $location in your $scope.RegisterView function to navigate to other page. something like this $location.path('/register/5426ced88b49d2e402402205')

jaybutani
  • 189
  • 1
  • 12
  • This makes sense, because `$http.get` as mentioned in the question is making a GET request and which doesn't redirect to a URL. – Royal Pinto Feb 12 '16 at 08:24
0

If you want to see your subdocument in seperate page then simply use :

<a target="_blank" >
  // apply target to that div where you are using subdocument
</a>

And if You have id in your register then you can directly call it as RegisterView(register.id)

$scope.RegisterView = function(id){
    $scope.IsVisible = $scope.IsVisible ? false : true;
    $http.get('/auth/register-list/' + id).success(function(response){
        $scope.bookinglist = response.booking;
    });
};

TEMPLATE

<button type="button" ng-click="RegisterView(register.id)"></button>
ojus kulkarni
  • 1,877
  • 3
  • 25
  • 41