I have this code in my controller.js file in AngularJS:
app.controller('MetaDetailGroupList', ['$scope', '$http', function($scope, $http) {
$http.get(Routing.generate('meta-detail-group-list')).success(function(data) {
$scope.MetaDetailGroup = data;
$scope.orderProp = 'name';
$scope.currPage = 0;
$scope.pageSize = 10;
$scope.totalMetaDetailGroup = function() {
return Math.ceil($scope.MetaDetailGroup.entities.length / $scope.pageSize);
};
}).error(function(data, status, headers, config) {
$scope.MetaDetailGroup.message = "Ocurrieron errores al procesar los datos, por favor vuelva a intentarlo.";
});
}]);
I use this function to build a list of items, it works fine. Some of those items has parent >> children relationship so I need to call the same function once again but this time passing and ID as a optional parameter to get the right childrens so the only change is this line:
From: $http.get(Routing.generate('meta-detail-group-list')).success(function(data)
To: $http.get(Routing.generate('meta-detail-group-list' + '/'+id)).success(function(data)
How I can do this without write another function just for this?