我在下面给出了一个响应,我需要将程序细节移动到一个数组中并在表格中显示它们。但是我收到了未定义的消息,因为programdetails又是一个数组。我的programdetails存储在newprogramdetails[]
中
如果我给ng-repeat它会给出重复的错误。
HTML:
<tr ng-repeat="item in newProgramDetails">
<td>{{newProgramDetails.title}}</td>
<td>{{newProgramDetails.description}}</td>
<td>{{newProgramDetails.createddate}}</td>
<td>{{newProgramDetails.updateddate}}</td>
</select></td>
</tr>
JS:
UserService.getProgram(json).then(function(response) {
$scope.newprograms = response.json.response.data;
for(var i=0;i<$scope.newprograms.length;i++){
newProgramDetails.push($scope.newprograms[i].programdetails);
}
});
JSON:
{
"json": {
"response": {
"servicetype": "4",
"functiontype": "4004",
"statuscode": "0",
"statusmessage": "Success",
"data": [
{
"programdetails": {
"id": 256,
"createddate": "2016-10-07 10:20:48",
"defaultprogram": true,
"description": "This is default program .",
"ppin": "000256",
"apin": "000256",
"owner": true,
"allowscheduling": false,
"points": 0,
"title": "Cakey Bakes Customer default program",
"updateddate": "2016-10-07 10:20:48",
"programtype": "Customer"
}
},
{
"programdetails": {
"id": 257,
"createddate": "2016-10-07 10:20:48",
"defaultprogram": true,
"description": "This is default program .",
"ppin": "000257",
"apin": "000257",
"owner": true,
"allowscheduling": false,
"points": 0,
"title": "Cakey Bakes Vendor default program",
"updateddate": "2016-10-07 10:20:48",
"programtype": "Vendor"
},
"userlist": [
{
"businessuserid": 44,
"businessusername": "rk business New",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": false,
"emailvalidated": false,
"email": "riteshnew@gmail.com",
"upin": "000044"
}
]
}
]
}
}
}
答案 0 :(得分:2)
答案 1 :(得分:0)
那里有运行时语法错误,
HTML:
<tr ng-repeat="item in newProgramDetails">
<td>{{item .title}}</td>
<td>{{item .description}}</td>
<td>{{item .createddate}}</td>
<td>{{item .updateddate}}</td>
</tr>