nour nour nour nour - 10 months ago 46
AngularJS Question

How to save an input value using AngularJS

I am working on a website that contains a field called comments where some particular users can post those comments.
My HTML code:

<input ng-model="stack"></input>
<button ng-click="save()">Save</button>
<p>Your comment: <span ng-bind="stack"></span></p>

The comments should be saved in to a variable then, posted in my web service which is a json file so I can do my Database calls. I have to use $
I am using AngularJS and I have written my webservice using java (JAXB).

$ = function() {
//In save I put alert to test because all the functions save I tested hadn't done what I need.
method: 'POST',
url: 'url',
data: "stack="


$ does it for you.

This is the html code :

<form ng-submit="save()">
      <input ng-model="stack"></input>
      <button type="submit">Save</button>
      <p>Your comment:<span ng-bind="stack"></span></p>
This is the controller function :

function myController($scope,$http){
      var data=$scope.stack;  
       /* post to server*/
        $, data)
          // success callback
           // failure callback