我正在显示一个来自json的列表,它具有一个单击按钮,该按钮将返回整个特定行对象。 我想使用Angular 8仅获取特定的json对象。
<table class="table1">
<tr>
<th>Job Name</th>
<th>Job Type</th>
<!-- <th>Immediate Priority</th> -->
<th>Start Time</th>
<th>Available Hywa</th>
<th>Required Hywa</th>
</tr>
<tr *ngFor="let obj of jobActivity">
<td>{{obj.csctsJob.jobName}}</td>
<td>{{obj.csctsJob.jobType}}</td>
<!-- <td>{{obj.csctsJob.immediatePriority}}</td> -->
<td>{{obj.csctsJob.startTimeline | date:'medium'}}</td>
<td>{{obj.csctsJob.availHywa}}</td>
<td>{{obj.csctsJob.reqHywa}}</td>
<td>
<span class="btn1 btn-xs" (click)="onEditJobAllocation(obj)">
<img src="/assets/edit-24px.svg" alt="edit">
</span>
</td>
</tr>
</table>
app.component.ts
onEditJobAllocation(obj){
console.log(obj);
}
它也返回了所有其他对象,但是我只想返回没有forloop或push方法的特定对象,请帮帮我。 我正在得到这样的json。
csctsJobActivityList:[
{ activityId: "ACT_1",
capacity: 100,
completedCapacity: 0,
createTimestamp: "2019-12-09T08:05:14.369+0000" ,
createUser: "mahan_admin" ,
fromStock: "STOCK_8",
jobId: "JOB_6",
reqHywa: null,
status: "INA" ,
toStock: "STOCK_10",
updateTimestamp: null },
{activityId: "ACT_1",
capacity: 100,
completedCapacity: 0,
createTimestamp: "2019-12-09T08:05:14.369+0000" ,
createUser: "mahan_admin",
fromStock: "STOCK_8",
jobId: "JOB_6",
reqHywa: null ,
status: "INA",
toStock: "STOCK_10" ,
updateTimestamp: null }]
我希望我的json可以不使用forLoop或push方法。
csctsJobActivityList:[
{ activityId: "ACT_1",
capacity: 100,
fromStock: "STOCK_8",
jobId: "JOB_6",
reqHywa: null,
status: "INA" ,
toStock: "STOCK_10",
},
{activityId: "ACT_1",
capacity: 100,
fromStock: "STOCK_8",
jobId: "JOB_6",
reqHywa: null ,
status: "INA",
toStock: "STOCK_10" ,
}]
答案 0 :(得分:0)
尝试此操作,它将仅返回与react-dom
相关的属性,而不返回您csctsJob
中可能存在的其他属性。
obj