Change $resource parameter AngularJS - angularjs

I'm using AngularJS $resource service.
After creating an instance of the resource, I'm trying to change one of the GET params.
The problem is that i keep getting the original value.
any ideas?
regards,
Iliya

Related

Is it mandatory to inject AngularJs service at first parameter in a function which has another parameters?

I have recently started learning AngularJs. I got errors while inject AngularJs service in a function. Later I have figured out that I need to follow the order when I inject service with other parameters in the function. I just wanted to know why we need to follow the order?

Controller Properties ASP.NET Core

Have 2 pages for one long process. Both in one controller. My problem is:
In first page, using angular - run method that generate some data. Store that data in property in controller. Move to another page, using angular - run another method and that is... my data in property is null. Is there a solution to store data in controller properties in thid situation?
New instance of a controller is created on every request so whatever you save in property of your controller this will be destroyed together with a controller when request is ended. You have to store this data either on client(cookie, local storage) or server side (session, cache, database etc.).
With ASP.Net MVC, you can't store data in a property between 2 actions.
For achieving this, you have to use cache strategy.
Please, see this link.

How to remove %22 from urls in angularjs

I am working in MVC 4 and using angularJs for client side scripting.I made an edit method which posts Id of the object to the MVC controller.When i click on edit . The url it generates is http://localhost:59568/NewsLetter/GetNewsLetterDataAng?id=%2256d6ac05afb241256469194b%22
but it should be
http://localhost:59568/NewsLetter/GetNewsLetterDataAng?id=56d6ac05afb241256469194b
Because of extra %22 in the front and end it is throwing 500 error.
Please suggest me how to remove it from the url
To complete the comment above I'll let you know an other thing about how to send and get data using angular js.
If you want to pass a json object to the server it's better to do it in a POST using the $http service builtin angular like in the example below:
$http.post(url, jsonObject){...};
By doing so, you send the json object as the body of the request and in asp.net-mvc the model binder can bind that json object to a class in your C# code.
In your case there is no need, as I said in the comments, for the JSON.stringfy method call when doing a GET request.

How to consume Spring Data Rest Webservices API with AngularJS

i had been working in a Spring Rest Data API in an application (just for fun).
I have the core made, works fine but now I want to use AngularJS as front-end.
I had work with Jackson (Mapping Java Objects to JSON), but with Spring Rest Data the Json response it's diferent, it has _embedded, _links, self, etc. links that make me confuse. I have something like this in the root url http://localhost/8080/app/api/tarifas
I have used a JS script called restangular but i have serveral problems (I'm newbie with Angular)
In my controller i have this
Check the error
If I add a RestangularProvider in my app.config(...) and change the Controller to getList instead get, works fine, but I need several entities data formats.
Any help it's welcome. If you know a better way please tell me.
Thanks!!
UPDATE
I found a form to do this (i donĀ“t know if it's the better) but now my problem is the next:
I have objects that has other objects as attributes (realtionship), and the reference in the JSON is a link (not an object). Then, in the grid; the value of the description's internal object is blank. To get the json data I found this
Now I have the next content for one register (one of the grid)
And my grid (In Angular, HTML) looks like this (empty fields)
How can I retrieve the attribute description from the member estado, categoria, etc. and show it in the grid. Should make the request to get it?
Thanks!!
You can use either angular.toJson or json.stringify
Angular-toJson documentation
Json.stringify documentation

Web API null parameter value in POST action

I'm trying to use angular and asp.net vNext Web API. I have a controller up but when using angular's $resource the object values are not resolved (Post method parameter is null)
The request itself has nothing out of the ordinary, though it does send json back. I think I've seen somewhere that vNext doesn't support content negotiation yet so maybe that's it. Can anyone confirm or shed some light on the subject?
Also - is there a way to get to the raw post data in Web API? (I'm using the core framework) cause the Request.Form that I know from mvc is not there any more. I tried the GetFormAsync but that returns an empty collection.
EDIT:
Confirmed that the reason for not binding the parameter is the fact that data is sent as JSON. When form encoding is used, the parameter values are resolved correctly.
using [FromBody] attribute on the param solved the issue.

Resources