I'm very new to Angular JS and am running into a slight snag. I'm sure this is probably easy to answer but my research so far has been unsuccessful.
I'm using Visual Studio as my IDE and have followed the tutorial here to start a project using AngularJS.
The initial output of the tutorial works great. What I'm trying to do now is add in support for reading a parameter from the url. Something like index.html?target=bob
I found this answer which shows the general methods for using $location to grab the paramters from the url and display the results on the page.
I am having issues applying this logic to my current structure. I assume it's something basic that I've missed so far so apologies if this question is too simplistic.
Here's my current code.
index.html
<!DOCTYPE html>
<html ng-app="app">
<head>
<title></title>
</head>
<body ng-controller="Main as vm">
<input type="text" ng-model="vm.food" placeholder="Enter food" />
<p>Sriracha sauce is great with {{vm.food}}!</p>
Target: {{vm.test}}<br />
<script src="Scripts/angular.min.js"></script>
<script src="app/app.module.js"></script>
<script src="app/main.js"></script>
</body>
</html>
app.module.js
(function () {
'use strict';
angular.module('app', [], function ($locationProvider) {
$locationProvider.html5Mode(true);
});
})();
main.js
(function () {
'use strict';
angular
.module('app')
.controller('Main', main($location));
function main($location) {
var vm = this;
vm.food = 'pizza';
vm.test = $location.search()['target']
}
})();
The page renders as such:
I am getting the following errors in the console which seem obvious but I'm at a loss as to what my next step should be.

Clearly the issue lies in main not understanding $location. But why? What do?!
Thanks!
SOLVED
Both Claise and squiroid provided excellent answers to this below. Since squiroid's solution is what I'm currently using I'll accept that answer but Claise's answer provides a bit more in depth information on this issue for future reference.
I'd like to note also that the second error listed above was solved by adding
<base href="/">to the head section of index.htmlThanks everyone!

$locationservice with[]if you are applying any automated minification.$scope: docs.angularjs.org/guide/controller