Question: I have the following code:`titledbApp.controller('TitleListController', ['$cookieStore', function($scope, $http, $cookieStore) {`

It **won't** work - It basically cants detect $CookieStore and says it's `undefined` so all .get and .put requests fail.

When I move `$cookieStore` in `function()` to the start (Before `$scope`) it works fine but then `$scope` and `$http` fail to work.

Full code:

```
titledbApp.controller('TitleListController', ['$cookieStore', function($cookieStore, $scope, $http) {
    $cookieStore.put('ETag', 'test');
    var etag = 't';
    $http.get('https://api.github.com/users/ImReallyShiny/repos', {headers: {'If-None-Match': 't'}}).then(function successCallback(response, headers) {
        $cookieStore.put('ETag', headers('ETag'));
        $scope.titles = response.data;
        $scope.titles.splice(1, 1);
        $scope.titles.sort(function(a, b){
            if(a.name.toUpperCase() < b.name.toUpperCase()) return -1;
            if(a.name.toUpperCase() > b.name.toUpperCase()) return 1;
            return 0;
        });
        }), function errorCallback() {
        return "Error";
        };
}]);

```

Answer: 
```
titledbApp.controller('TitleListController', ['$cookieStore', function($cookieStore, $scope, $http)

```

Should be

```
titledbApp.controller('TitleListController', ['$cookieStore', '$scope', '$http', function($cookieStore, $scope, $http)

```

You have to inject them all before you can access them in your code.
According to angular js official documentation, the order and the no: of parameters of the dependencies should be same.

```
titledbApp.controller('TitleListController', ['$cookieStore','$scope', '$http', function($cookieStore, $scope, $http) {
    $cookieStore.put('ETag', 'test');
    var etag = 't';
    $http.get('https://api.github.com/users/ImReallyShiny/repos', {headers: {'If-None-Match': 't'}}).then(function successCallback(response, headers) {
            $cookieStore.put('ETag', headers('ETag'));
        $scope.titles = response.data;
        $scope.titles.splice(1, 1);
        $scope.titles.sort(function(a, b){
            if(a.name.toUpperCase() < b.name.toUpperCase()) return -1;
            if(a.name.toUpperCase() > b.name.toUpperCase()) return 1;
            return 0;
        });
        }), function errorCallback() {
        return "Error";
        };
}]);

```

**You can also use the function syntax,**

```
titledbApp.controller('TitleListController', TitleListController);

function TitleListController($cookieStore,$scope, $http){
    $cookieStore.put('ETag', 'test');
    var etag = 't';
    $http.get('https://api.github.com/users/ImReallyShiny/repos', {headers: {'If-None-Match': 't'}}).then(function successCallback(response, headers) {
            $cookieStore.put('ETag', headers('ETag'));
        $scope.titles = response.data;
        $scope.titles.splice(1, 1);
        $scope.titles.sort(function(a, b){
            if(a.name.toUpperCase() < b.name.toUpperCase()) return -1;
            if(a.name.toUpperCase() > b.name.toUpperCase()) return 1;
            return 0;
        });
        }), function errorCallback() {
        return "Error";
        };

}

```