I am new to Angular.js and trying to get work with routing, but in my application the second lower route does not call listController, so I am not returning data.
I went through many working examples, but I can not understand why this does not work in my application? I am returning the template back /Categories/SixGrid, but as mentioned, the controller does not seem to be called. Is there something obvious I'm not mistaken? Or can someone share their knowledge on why this might not work?
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;
});
});
source
share