I have recently started to learn and use AngularJS and I'm still unclear about some concept.

My question is this: in my app I have a controller which uses `$http` to retrieve data from my back-end as soon as it is initialised. Following the excellent tutorial from CodeSchool on Angular I came up with this:

```
app.controller("agentController", function ($http) {
    var agentsCtrl = this;
    agentsCtrl.agents = [];
    $http.get("getAgents").success(function (data) {
        agentsCtrl.agents = data;
    });
...

```

HTML: 

```
<div ng-controller="agentController as agentCtrl">
    <div ng-repeat="agent in agentCtrl.agents">
...

```

This works fine, but I'm unclear on why I would need to declare the controller as a variable within itself using `this`. From what I understand it's because by doing this I can then call it within the `$http` service, where the `this` keyword would return the wrong scope. Is this correct?

I found that this also works:

```
app.controller("agentController", function ($http, $scope) {
    $scope.agents = [];
    $http.get("getAgents").success(function (data) {
        $scope.agents = data;
    });

```

HTML:

```
<div ng-controller="agentController as agentCtrl">
    <div ng-repeat="agent in agents">
...

```

I guess this works because I explicitly inject the scope and use it within the service. Also, the HTML is now slightly different. In the first case I need to explicitly call `agentCtrl.agents`, while with scope simply call on `agents`. This is still because the variable is now declared on the scope rather than the controller? Is this correct?

What is the best practice to use in similar cases?

Thank you!