Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing param object from $resource get method to restful services
    primarykey
    data
    text
    <p>i have query regarding passing param objects to $resource get method.</p> <p>in the backend restful application i am not getting the routeparam values passed . here my sample code</p> <p>on clicking the search button from the html page it is moving to controller as mentioned in myapp.js</p> <p>myapp.js var app = angular.module('myApp', [ 'MyServices']);</p> <p>app.config([ '$routeProvider', function($routeProvider) {</p> <pre><code>$routeProvider .when('/employeesearch/:empID/:deptID', { templateUrl : 'partials/result.html', controller : SearchController }) .otherwise({ redirectTo : '/defaultsearch' });} ]); </code></pre> <p>on doing console.log in controller.js file , the routeparams values are displayed correctly</p> <p>SearchController.js</p> <p>function SearchController($scope, $routeParams, EmployeeSearch) $scope.mydata = EmployeeSearch.getSearchResult($routeParams.empID,$routeParams.deptID);</p> <p>}</p> <p>myservices.js</p> <p>angular.module('MyServices', ['ngResource']).</p> <pre><code>factory('EmployeeSearch', function($resource){ return $resource('rest/employees/:eID/:dID', {}, { query: {method:'GET', params:{}, isArray:false}, getSearchResult:{method:'GET', params:{eID:'empID',dID:'deptID'}} }); }); </code></pre> <p>backend restful java class</p> <p>@Path("/employees") public class EmployeeSearchService {</p> <p>@Path("{eID}/{dID}")</p> <p>@GET</p> <p>@Produces(MediaType.APPLICATION_JSON)</p> <p>public Employee searchmethod(@PathParam("eID") String empId, @PathParam("dID") String deptId) { </p> <pre><code> System.out.println("eid:"+empId); System.out.println("did:"+deptId); return new Employee(); } </code></pre> <p>on hitting the restful url :http:localhost:9080/MyProject/rest/employees/e12/d12<br> - the value of eid is 'e12' and did is "d12"</p> <p>but on hitting via the anugular it is displaying the value of eid as "empID" and did as "deptID",</p> <p>it is displaying the value as i mentioned in the myservices.js file</p> <p>Can you please help me out in this? what am i giving wrongly?</p> <p>Reference site: <a href="https://github.com/teunh/jfall2012/blob/master/demo/web/index.html" rel="nofollow">https://github.com/teunh/jfall2012/blob/master/demo/web/index.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload