0

I am new to angular js. I am trying to set a value in object in list object.

Model class
public class InfoModel{
    public List<TestInfo> testInfo;
    public void setTestInfo(List<TestInfo> testInfo){this.testInfo=testInfo;}
    public List getTestInfo(){return testInfo;}
    public int amount=0; //we have setters and getters for amount
}

TestInfoclass
public class TestInfo{
    public User user;
    public void setUser(User user){this.user=user;}
    public User getUser{return user;}
}

User object has name and id.

In angular controller
$scope.submitStatus = function(form1){
    $scope.infoModel.testInfo=[];
    var user; 
    if($scope.infoModel.amount<=6000){
       user = form1[0].user;
    } else {
       user = form1[1].user;
    } //Now I need to assign var user to TestInfo object at 0th location.
}

Please help in this. Thanks a lot for your help and time on this.

Thanks Rama

2
  • Does this have anything to do with Java? Commented Jun 19, 2018 at 14:31
  • Java and angular js Commented Jun 19, 2018 at 14:33

1 Answer 1

1

Is this what you are looking for?

var testInfo = {user: user};
$scope.infoModel.testInfo.push(testInfo);

This creates a javascript object and add it to the list of testInfos.

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.