var app = angular.module("frontApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "view/main.html"
})
.when("/category/:catalogId", {
templateUrl : "view/catalog.html",
controller:"CategoryCtrl"
})
.when("/product/:productId", {
templateUrl : "view/product.html",
controller:"ProductCtrl"
})
.when("/catalog", {
templateUrl : "view/catalog.html",
controller:"CatalogCtrl"
})
.when("/download", {
templateUrl : "view/download.html"
})
.when("/contact", {
templateUrl : "view/contact.html"
});
});
app.controller('CategoryCtrl',['$scope','$http','$routeParams',
function($scope,$http, $routeParams){
var catalogId = $routeParams.catalogId;
var url = '/api/item/catalog/'+1+'/'+ catalogId;
console.log(url);
$http.get(url).success(function(data) {
$scope.categories=data.categories;
$scope.catalog=data.catalog;
});
}]);
app.controller('CatalogCtrl',['$scope','$http','$location', '$routeParams',
function($scope,$http){
var url = '/api/item/catalog/';
console.log(url);
$http.get(url).success(function(data) {
$scope.categories=data.categories;
$scope.catalog=data.catalog;
});
}]);
<div class="b-blog__aside-categories wow zoomInUp" data-wow-delay="2.3s">
<header class="s-lineDownLeft">
<h2 class="s-titleDet">Категории</h2>
</header>
<nav>
<ul class="b-blog__aside-categories-list" ng-repeat="category in categories">
<li><a href="#/category/{{category.slug}}">{{category.name}}</a></li>
</ul>
</nav>
</div>