1
$scope.addUpdateList = function (item){
     $scope.targetlist.push(item);
}

$scope.updateTarget = function(){
     $http.post('${pageContext.request.contextPath}/products/productsUpdate',
                {targetList: $scope.targetList});
}

body

<tr ng-repeat="item in selectResult track by $index | orderBy : 'itemID'">
<td><input ng-change="addUpdateList(item)" type="text" ng-model="item.siteCode" disabled></td>
<td><input ng-change="addUpdateList(item)" type="text" ng-model="item.itemID" disabled></td>
<td><input ng-change="addUpdateList(item)" type="text" ng-model="item.itemName"></td>
<td><input ng-change="addUpdateList(item)" type="text" ng-model="item.itemAmt"></td>
<td><select ng-change="addUpdateList(item)" ng-model="item.kitchenPRT_Y">
    <option>Y</option>
    <option>N</option>
</select>
</td>

chrome error

TypeError: Cannot read property 'push' of undefined at m.$scope.addUpdateList

spring error

14:48:52.812 [tomcat-http--43] DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolving exception from handler [public void sipos.gim.pos.main.controller.ProductsinfomationController.productsUpdate(java.util.Locale,org.springframework.ui.Model,java.security.Principal,java.util.List,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1] 14:48:52.812 [tomcat-http--43] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [public void sipos.gim.pos.main.controller.ProductsinfomationController.productsUpdate(java.util.Locale,org.springframework.ui.Model,java.security.Principal,java.util.List,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1] 14:48:52.812 [tomcat-http--43] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [public void sipos.gim.pos.main.controller.ProductsinfomationController.productsUpdate(java.util.Locale,org.springframework.ui.Model,java.security.Principal,java.util.List,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: org.apache.catalina.connector.CoyoteInputStream@c42dd57; line: 1, column: 1]

What's wrong the code?

2
  • $scope.addUpdateList=function(item){ Commented Jan 29, 2016 at 5:23
  • No worries. Can't comment on your new issue without more code. Basically the error is teling you that $scope.targetlist is not defined. You need to initialize it somewhere in your code -- probably with $scope.targetlist = []; Commented Jan 29, 2016 at 6:03

1 Answer 1

0

Please correct below code:

$scope.addUpdateList(item){
  $scope.targetlist.push(item);
}

With:

$scope.addUpdateList = function(item){
  $scope.targetlist.push(item);
}

Error: $injector:modulerr Module Error

Failed to instantiate module myApp due to: {1}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.