Angular controller not being called

angularjs, asp.net-mvc, c#, html, javascript

Solution

Try to wrap controller name in quotes:

$routeProvider.when('/Categories/List/:slug', {
    templateUrl: '/Categories/SixGrid',
    controller: 'listController'
});

Also good practice is to define controllers by this way (because global scope remains clean):

angular.module('App').controller("listController", function () {
    //controllerCode
});

Problem

I am new to Angular.js and trying to get get routing working but in my app the second bellow route does not call the `listController` so I am not getting back data. I have been through many working examples but cannot seem to work out why this is not working in my app? I get the template back `/Categories/SixGrid` but as mentioned the controller seem to not being called. Is there something obvious I am not doing wrong? Or can anyone share their knowledge on why this may not be working? Updated code: ``` angular.module('App', ['App.Controller']). config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/', { templateUrl: '/Home/Splash' }); $routeProvider.when('/Categories/List/:slug', { templateUrl: '/Categories/SixGrid', controller:'listController' }); }]); angular.module('App.Controller', []) .controller("listController", function ($scope, $http) { $http.get('../../api/cat/' + $routeParams.slug).success(function (data) { $scope.products = data; }); }); ```

Original source