Table is generating only by static data but not by dynamically as per the service response data
See original GitHub issueif i pass table data as statically like below then only my table is showing rows constructor(public service:ViewListCustomerServiceService) { this.data=[ { id:1, “name”:“Customer 1”, “details”:“Customer 1”, “active”:false }, { “id”:2, “name”:“Customer 2”, “details”:“Customer 2 details goes here”, “active”:false }]; }
but if i assign data from service responded data then i am getting error at browser console as
main.bundle.js:50104EXCEPTION: Error in ./ViewListCustomersComponent class ViewListCustomersComponent - inline template:70:100 caused by: ‘undefined’ is not a function (evaluating ‘source.setPaging(1, this.getSetting(‘pager.perPage’), false)’) main.bundle.js:50106ORIGINAL EXCEPTION: ‘undefined’ is not a function (evaluating ‘source.setPaging(1, this.getSetting(‘pager.perPage’), false)’) main.bundle.js:50113ERROR CONTEXT: main.bundle.js:50114 DebugContext main.bundle.js:108412 ViewWrappedError
Here is my constructor in component constructor(public service:ViewListCustomerServiceService) { this.service.getCustomerItemList().then(lst =>this.data=(lst)); }
Here is my service @Injectable() export class ViewListCustomerServiceService {
constructor(private http:Http) { }
getCustomerItemList():Observable<CustomerDetailsItem[]> { let response = this.http.get(`${AppSettings.BACK_ENDPOINT}/list-customers); let customerDetailItems = response.map(mapCustomerItems).toPromise(); return customerDetailItems; } }
function mapCustomerItems(response:Response):CustomerDetailsItem[] { let customerDetailsItem =response.json().map(toCustomerItem); return customerDetailsItem; }
function toCustomerItem(r:any):CustomerDetailsItem { let customerDetailItem = <CustomerDetailsItem>({ id:r.id, name:r.name, details:r.details, active:r.active, }); return customerDetailItem; }
if i print my service response to console then i am getting array of Objects eg. [Object, Object]
i also searched about this issue then found that before response coming from Service then component is calling. please suggest me about this issue.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7
Top GitHub Comments
I think you can try something like this:
Confirm. Have same issue.