I have an app that has the ability to get and post through http with a model of a relational database. I am able to display my data and the JSON data looks like this on http://localhost/**/api/complaint:
{
"CHECKLISTs": [{
"COMP_ID": 1,
"IntOIMRec": "No"
}],
"COMP_ID": 1,
"FileNum": "case1"
}
using angular:
<tr data-ng-repeat="complaint in complaints">
<td><strong data-ng-hide="complaint.editMode">{{ complaint.FileNum }}</strong></td>
<td>
<p data-ng-hide="complaint.editMode">{{ complaint.CHECKLISTs[0].IntIAB}}</p>
<input data-ng-show="complaint.editMode" type="text" data-ng-model="customer.Status" />
</tr>
I am also able to http post with this controller:
//Insert complaint
$scope.add = function () {
$scope.loading = true;
$http.post('/api/Complaint/', this.newcomplaint).success(function (data) {
alert("Added Successfully!!");
$scope.addMode = false;
$scope.complaints.push(data);
$scope.loading = false;
}).error(function (data) {
$scope.error = "An Error has occured while Adding complaint! " + data;
$scope.loading = false;
});
};
But when I add the Checklists[0] to my form to add it, it will not add a new record. My code for the form to add a new record looiks like this:
<div class="row">
<div class="col-md-12">
<strong class="error">{{ error }}</strong>
<p data-ng-hide="addMode"><a data-ng-click="toggleAdd()" href="javascript:;" class="btn btn-primary">Add New</a></p>
<form name="addComplant" data-ng-show="addMode" style="width:600px;margin:0px auto;">
<div class="form-group">
<label for="cid" class="col-sm-2 control-label">ID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="cid" placeholder="please enter id" data-ng-model="newcomplaint.FileNum" required />
</div>
</div>
<div class="form-group">
<label for="cname" class="col-sm-2 control-label">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="cname" placeholder="please enter your name" data-ng-model="newcomplaint.CHECKLISTs[0].IntIAB" />
</div>
</div>
<br />
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" value="Add" data-ng-click="add()" class="btn btn-primary" />
<input type="button" value="Cancel" data-ng-click="toggleAdd()" class="btn btn-primary" />
</div>
</div>
<br />
</form>
</div>
</div>
my console.log output:
Can someone tell me if I can display it using angular http.get and http.post, why can't I add into checklists field when it is clearly in the JSON file and it displays just fine? The error i get is [object object] ?
Thank you
data
from the success handler and add it to the question.