Pages

Thursday, 10 September 2015

how to send string with spaces in angular js post method



I had also faced this problem. searched altos on several websites finally i came across to a logic.
I know this is not a good option but its an alternative to send the data using angular post method.

So here is the  method:-

1. Replace your string with any special character which not commonly used.
2.After replacing send the data  using param of angular post method.

On Server-Side  I am using Java Restful Web-service.

Replace that Special Character with space. that's it.

Example:-

In Angular JS Controller:-

var str='Ashish Shukla';
str=str..replace(/\s+/g, '#');


On Server Side

String demo=request.getParameter("str");
    demo= demo.replaceAll("[#]*", "");


Till then keep asking  :-)



9 comments:

  1. This is my first time visit on your site and i have bookmark this for again visit. thanks a lot of for share a appreciable post ..
    Angularjs Training In Hyderabad

    ReplyDelete
    Replies
    1. Your welcome.
      If you find any difficulties while using ionic or angular js .just leave in the comment box.
      Will back you soon

      Delete
  2. I have read your blog its very attractive and impressive. I like it your blog.

    Angularjs Training in Chennai

    ReplyDelete
  3. Thanks for sharing with us that awesome article you have amazing blog…..
    Angular JS Training in Hyderabad

    ReplyDelete