rest - Angularjs RESTul Resource Request -


i trying make request

....port/trimservice/fragments/?fragment_name=:fragmentname 

however if try make "?fragment_name" parameter, breaks. going have more requests, action change cannot leave in url portion of resource.

angular.module(foo).factory('fragmentservice', ['$resource', function ($resource) {     var fragmentservice = $resource('.../fragments/:action:fragmentname',     {},     {         'getfragments':         {             method: 'get',             isarray: true,             params:             {                 fragmentname: "@fragmentname",                 action: "?fragment_name="             }         }      });     return fragmentservice; } ]); 

as of right now, have no idea url outputting.

edit: changed resource /u/akonsu had mentioned below. added controller still not working correctly.

angular.module(foo).factory('fragmentservice', ['$resource', function ($resource) {     var fragmentservice = $resource('.../fragments/',     {},     {         'getfragments':         {             method: 'get',             isarray: true,             params:             {                 fragmentname: "@fragmentname",             }         }      });     return fragmentservice; } ]);   angular.module(foo).controller('fragmentcontroller', ['$scope', 'fragmentservice', function ($scope, fragmentservice) {     $scope.fragmentquery = {         fragmentname: 'a',     };       $scope.fragmentquery.execute = function ()     {         if ($scope.fragmentquery.fragmentname == '')         {             $scope.fragments = {};         }         else         {             $scope.fragments = fragmentservice.getfragments(             {                 fragmentname: $scope.fragmentquery.fragmentname,             });         }     };     $scope.fragmentquery.execute();  } 

]);

try omitting query string altogether in resource url , supply fragmentname parameter action call. should add query string if not in list of url parameters.

$resource(".../port/trimservice/fragments/").get({fragmentname: 'blah'}) 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -