Angular 4 ngx-treeview integration with json response -


i'm new angular 4 , using ngx-treeview(https://www.npmjs.com/package/ngx-treeview) tree structure. using static data able bind view tree.

but need use rest service tree structure hence created similar class treeviewitem ngx-treeview

public class treeviewitem {     public string text { get; set; }     public int value { get; set; }     public bool collapsed { get; set; }     public treeviewitem[] children { get; set; } }  

here json response i'm getting

[{"text":"core fields","value":100,"collapsed":false,"children":null}] 

angular service:

return this.http.get(this.apphelperssvc.apiaddress +  "api/module/getstandardfields", { headers: httpheaders }) .map((response:response) => <treeviewitem>response.json()); 

angular component

itemslist: treeviewitem[];  this.moduleservice.getstandardfields().subscribe(data => {this.itemslist = data;});  

doing i'm getting

uncaught typeerror: this.items[i].getcheckeditems not function @ treeviewcomponent.getcheckeditems (http://localhost:4001/main.bundle.js:42763:107) @ treeviewcomponent.raiseselectedchange (http://localhost:4001/main.bundle.js:42745:34) @ treeviewcomponent.ngonchanges (http://localhost:4001/main.bundle.js:42703:22) @ checkandupdatedirectiveinline (http://localhost:4001/vendor.dll.js:12160:19) @ checkandupdatenodeinline (http://localhost:4001/vendor.dll.js:13586:17) @ checkandupdatenode (http://localhost:4001/vendor.dll.js:13525:16) @ debugcheckandupdatenode (http://localhost:4001/vendor.dll.js:14228:59) @ debugcheckdirectivesfn (http://localhost:4001/vendor.dll.js:14169:13) 

not able understand going wrong. help.

i author of component. need map json list of treeviewitem:

const list = items.foreach(item => new treeviewitem(item)); 

and binding list component.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -