1
I created a Webservices to receive query by string and return a list, example:
url/mePath/Luiz - Since Luiz is the parameter that will be passed, based on this parameter will return me a list of Luiz.
In Angularjs I can: List All, Search by ID, Delete, Change and I can’t pass a parameter as a string. Follow the code snippet:
reportServices.factory('MeuServico', ['$resource',
function($resource){
return $resource('/url/meuPath/:nome', {}, {
query: { method: 'GET', isArray: true },
queryParameter: { method: 'GET', params: {query: '@nome'} , isArray: true,}
});
}]);
Angularjs generates the url like this: /url/meuPath?0=%2F&1=a&2=b&3=e&4=r&5=t&6=a
As he generated in this way the Angularjs discards the q comes after the "?" and ends up falling in the service to list all.
NOTE: if I change the /url/meuPath/:nome
for /url/meuPath/nome
query is done correctly by passing the variable name and not the value.
Solution
My mistake occurred by the following:
When I called the service I was doing so:
MeuServico.Query("Amarelão");
Since I should call it that:
animal.nome = "Amarelão";
MeuServico.Query(animal);
By doing this the service can access the services of the service without generating the URL as if the parameter were an array
Recently I did a series of slides for a course here at the company that was just about that: Integration with Angular and Webapi. At the end of the course I posted the slides on Slideshare, take a look, it may be useful. http://pt.slideshare.net/anisanwesley/angular-jumpstart-1-introduo-38460785 The description of this one contains the other slides
– anisanwesley