Thanks to the help of JoelCDoyle from a previous question that I asked ([overflow question](https://stackoverflow.com/questions/38624433/inserting-json-id-key-into-ng-click-directive-and-then-pass-that-into-another-co)), I am able to grab an ID from a JSON key value and pass it to another controller in order to append the end a API address being called.

Here is the code that is working from the previous post:

```
CarDetailService.$inject = ['$http', 'API'];
function CarDetailService($http, API) {
  var CarDetailService = this;
  CarDetailService.setCar = function(carId) {
    CarDetailService.carId = carId;
  };

  CarDetailService.getCar = function() {
    return $http.get(API + "/car/" + CarDetailService.carId);
  };
}

myTasks.$inject = ['$scope', '$http', 'API', 'CarDetailService', '$state'];
function myTasks($scope, $http, API, CarDetailService, $state) {
  $http.get( API + '/tasks' ).
  success(function(data) {
    $scope.mainTask = data;
    console.log(data);
  });

  $scope.selectCar = function(carId) {
    CarDetailService.setCar(carId);
    $state.go('taskDetails');
  };
}

// EDITED
carDetails.$inject = ['$scope', 'CarDetailService', '$http', 'API'];
function carDetails($scope, CarDetailService, $http, API) {
  // console.log('Post injection: ' + CarDetailService.carId);
  CarDetailService.getCar().success(function(details) {
    $scope.details = details;
  });
}

```

now I have been able to add it to a another controller by just copying the code from the other one and changing a few things like so:

```
myCars.$inject = ['$scope', '$http', 'API', 'CarDetailService', '$state'];
function myCars($scope, $http, API, CarDetailService, $state) {
  $http.get( API + '/car' ).
  success(function(data) {
    $scope.myCars = data;
    console.log(data);
  });

  $scope.selectCar = function(carId) {
    CarDetailService.setCar(carId);
    $state.go('taskDetails');
  };
}

```

But right now I have two other controllers that I need to add it to and I can't seem to get those to work.

**First One** should be as simple as the first two. I just copied the previous one and changed a few things like I did before:

```
observedCars.$inject = ['$scope', '$http', 'API', 'CarDetailService', '$state'];
function observedCars($scope, $http, API, CarDetailService, $state) {
  $http.get( API + '/car/?observed=true&offset=0&page_size=20' ).
  success(function(data) {
    $scope.observed = data;
    console.log(data);
  });

  $scope.selectCar = function(carId) {
    console.log('Car ID is ' + carId);
    CarDetailService.setCar(carId);
    $state.go('taskDetails');
    console.log( 'Get Car is ' + CarDetailService.carId);
  };
}

```

As you can see I have the output of the id being logged into the console to make sure it is grabbing the ID and it does. It prints in the console the carID and CarDetailService.carId so that tells me that it is grabbing the right id but it is not injecting it into the *carDetails* controller. I am stumped for the most part. I am pretty sure that it has something to do with the original API call from the observedCars controller:

```
 /?observed=true&offset=0&page_size=20

```

But again it still grabs the proper ID bust just doesn't inject it into the *carDetails* controller. 

The HTML ng-click references are as so:

```
<div ng-repeat="task in mainTask.Tasks" class="myCar">
    <div class="viewCar"><a ng-click="selectCar(task['CAR ID'])">View Details</a></div>
</div>

<div ng-repeat="car in myCars['My CARs']" class="myCar">
    <div class="viewCar"><a ng-click="selectCar(car['CAR ID'])">View Details</a></div>
</div>

<div dir-paginate="obv in observed['Observed CARs'] | filter:q | itemsPerPage: 5" class="myCar">
    <div class="viewCar"><a ng-click="selectCar(obv['CAR ID'])">View Details</a></div>
</div>

```

**Second One** I can't figure out is my search controller. It does the same thing as the observedCars controller. This one also logs the proper CAR ID in the console but when the state changes it does not load the ID info of the one that it grabbed.

Here is that code:

```
function searchRes($scope, $http, API){

  $scope.$watch('search', function() {
    fetch();
  });

  $scope.currentPage = 1;
  $scope.pageSize = 5;

  function fetch(){
    $http.get(API + "/search/" + $scope.search)
    .then(function(data){ 
      $scope.results = data;
    });
  }

  $scope.select = function(){
    this.setSelectionRange(0, this.value.length);
  }

  $scope.selectCar = function(carId) {
    console.log('Car ID is ' + carId);
    CarDetailService.setCar(carId);
    $state.go('taskDetails');
    console.log( 'Get Car is ' + CarDetailService.carId);
  };
}

```

Any help is greaaaaatly appreciated!