我从getView()
方法得到一个对象,d并且该对象包含一个名称列表。我希望这些名称存储在一个数组中。我怎么能这样做?
getView() {
return this.http.get(this.viewUrl).map(response => response.json());
}
Component.ts
constructor(private userService: userservices, private route: Router){
this.userService.userView().subscribe(data => {this.userData = data.nameKey, alert(data)},
err => {
console.log('Error get values from services in Branch Component');
});
alert(this.userData);
this.itemResource = new DataTableResource(this.userData);
}
DataTable.html
<data-table id="persons-grid" headerTitle="Employees View"
[items]="items" [itemCount]="itemCount" (reload)="reloadItems($event)"
(rowClick)="rowClick($event)"
(rowDoubleClick)="rowDoubleClick($event)" [rowTooltip]="rowTooltip">
<data-table-column [property]="'name'" [header]="'Name'"
[sortable]="true" [resizable]="true"> </data-table-column> <data-table-column
[property]="'email'" [header]="'Branch Name'" [sortable]="true"
[resizable]="true"> </data-table-column>
我参考了这个链接https://www.npmjs.com/package/angular-4-data-table-bootstrap-4
答案 0 :(得分:1)
试试这个。
getView() {
return this.http.get(this.viewUrl).map(response => response.json());
}
this.getView().subscribe((data) => {
this.arrayValue=data.nameKey;
alert(JSON.stringify(this.userData));
})