I am using Spring MVC framework and using AngularJs in the front page. I 
need to get post JSON Data to restservice. Everything works fine with the 
service that tests and coding from main file is fine. But the problem is 
when I try to post data by using Angular Js it fails. Could you please 
check my js and jsp file where data is listed and tell me where I make 
mistake . I am looking forward for your helps.

Regards Alper Kopuz


JS File :

var helloAjaxApp = angular.module("helloAjaxApp", []);

helloAjaxApp.controller("ItemsCtrl", ['$scope', '$http', function($scope, 
$http) {
$scope.item = [
                    { 'name':'burger',
                        'price': 1.99},                                     
                    ];

$scope.addRowAsyncAsJSON = function(){      
    $scope.companies.push({ 'name':$scope.name, 'price': $scope.price});
    // Writing it to the server
    //  
               var dataObj = {
            name : $scope.name,
            price : $scope.price
    };  
    var res = $http.post('/item', dataObj);
    res.success(function(data, status, headers, config) {
        alert('going to other method 5' );      
    $scope.message = data;
    });
               alert('going to other method 4' );
    res.error(function(data, status, headers, config) {
        alert( "failure message: " + JSON.stringify({data: data}));
    });     
    $scope.name='';
    $scope.price='';};}]);

JSP where data result is listed:

    <div ng-controller="item">
        <p>The ID is {{item}}</p>
        <p>The content is {{item.id}}</p>
    </div>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to