I have a simple create page which has list of label and date objects, rendered through data from rest api /restapi/reportTypes. On clicking the Save button I want to save all the data, by calling rest api /restapi/entity. But all the reportTypes objects are passed through the main object called entity.
Web page looks like this
Javascript
crudApp.controller('addController', function($scope, $http, $location) {
$http.get("/restapi/reportTypes").success(function(data, status, headers, config) {
$scope.reportTypes = data;
});
$scope.add = function() {
$http.post("/restapi/entity", $scope.entity).success(function(data, status, headers, config, statusText) {
$location.path('/list');
}).error(function(data, status, headers, config, statusText) {
console.log("Error : " +statusText);
});
}
}
HTML
<div class="form-group" ng-repeat="reportType in reportTypes">
<label class="control-label col-md-3">{{reportType.label}}</label>
<div class="input-group col-md-4">
<input id="startDate" type="text" class="form-control" ng-model="reportType.startDate">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">NOTES</label>
<div class="col-md-7">
<input type="text" ng-model="entity.notes" class="form-control">
</div>
</div>
<input type="submit" value="Add" ng-click="add()">
For that when I try with below code,
<div class="form-group" ng-repeat="reportType in entity.reportTypes">
I get error
Error: $scope.entity is undefined
Updated:
Here is my Entity class,
public class Entity {
private List<ReportType> reportTypes;
private String notes;
// getter / setters
}

$scope.entitysupposed to represent? it's not defined here in this code before it is used.Entity, that's not the same as the$scopepropertyentity; where are you defining$scope.entity?reportTypes, a form that is iterating through each of those and outputting a label and what appears to be a date, followed by an unrelated single string of notes, and a post method that seems to be posting to an API that wants both of those as a single object.