Search code examples
angularjsrestangular

Pass parameters in RESTAngular


I am using angularJS, RESTangular.

I need to pass 3 parameter. When I an passing 1 parameter like below, I am getting data

subjectAllocationEdit: function (Restangular, $stateParams ) {
                                return Restangular.one('subjectAllocationEdit', $stateParams.classId).get();
                            }

BUT if I am passing 3 parameter like below, I am NOT getting data and even I am not able to parameters passing to my PHP end.

subjectAllocationEdit: function (Restangular, $stateParams ) {
                                return Restangular.one('subjectAllocationEdit', $stateParams.classId, $stateParams.sectionId, $stateParams.Type).get();
                            }

when hitting my api like /http/../../subjectAllocationEdit/4/9/main I am getting records

full state code is as below
How I can pass 3 parameters? or what should be the alternate

.state('subjectAllocationEdit', {
                        url: '/class/subjectAllocation/:classId/:sectionId/:Type',
                        templateUrl: 'app/class/html/subjectAllocation.html',
                        controller: 'subjectAllocationEditCtrl as vm',
                        resolve: {
                            subjectAllocation: function (Restangular, $stateParams) {
                                return Restangular.all('subjectAllocation').getList();
                            },
                            subjectAllocationEdit: function (Restangular, $stateParams ) {
                                return Restangular.one('subjectAllocationEdit', $stateParams.classId, $stateParams.sectionId, $stateParams.Type).get();
                            },
                        }
                    })

Solution

  • subjectAllocationEdit: function (Restangular, $stateParams) {
                                    return Restangular.all('subjectAllocationEdit')
                                        .getList({"classId":$stateParams.classId,"sectionId":$stateParams.sectionId,"Type":$stateParams.Type});
                                },