将 ORDS 连接到 Angular
Connecting ORDS to Angular
我正在从我的 ORDS 服务器检索 json 格式的数据,它看起来像这样:
{"items":[{"cust_code":"C00013","cust_name":"Holmes","cust_city":"London
","working_area":"London","cust_country":"UK","grade":2,"opening_amt":6000,"receive_amt":5000,"payment_amt":7000,"outstanding_amt":4000,"phone_no":"BBBBBBB","agent_code":"A003
"},{"cust_code":"C00001","cust_name":"Micheal","cust_city":"New York
","working_area":"New
York","cust_country":"USA","grade":2,"opening_amt":3000,"receive_amt":5000,"payment_amt":2000,"outstanding_amt":6000,"phone_no":"CCCCCCC","agent_code":"A008
"},{"cust_code":"C00020","cust_name":"Albert","cust_city":"New York
","working_area":"New
York","cust_country":"USA","grade":3,"opening_amt":5000,"receive_amt":7000,"payment_amt":6000,"outstanding_amt":6000,"phone_no":"BBBBSBB","agent_code":"A008
"},{"cust_code":"C00025","cust_name":"Ravindran","cust_city":"Bangalore
","working_area":"Bangalore","cust_country":"India","grade":2,"opening_amt":5000,"receive_amt":7000,"payment_amt":4000,"outstanding_amt":8000,"phone_no":"AVAVAVA","agent_code":"A011
"},{"cust_code":"C00015","cust_name":"Stuart","cust_city":"London
","working_area":"London","cust_country":"UK","grade":1,"opening_amt":6000,"receive_amt":8000,"payment_amt":3000,"outstanding_amt":11000,"phone_no":"GFSGERS","agent_code":"A003
"}],"hasMore":false,"limit":25,"offset":0,"count":5,"links":[{"rel":"self","href":"http://localhost:9000/ords/demo/customers/getAll/"},{"rel":"describedby","href":"http://localhost:9000/ords/demo/metadata-catalog/customers/getAll/"},{"rel":"first","href":"http://localhost:9000/ords/demo/customers/getAll/"}]}
所以我想知道是否有办法分解项目部分并使用 anguler 将其放入表格中。
我尝试在我的 ts 文件中使用这种方式:
http.get('http://localhost:9000/ords/demo/customers/getAll/')
.subscribe(data => this.items = data);
但是我一直收到这个错误:
Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed
你想要的数组在items
属性所以你必须做
http.get('http://localhost:9000/ords/demo/customers/getAll/')
.subscribe(data => this.items = data.items);
我正在从我的 ORDS 服务器检索 json 格式的数据,它看起来像这样:
{"items":[{"cust_code":"C00013","cust_name":"Holmes","cust_city":"London ","working_area":"London","cust_country":"UK","grade":2,"opening_amt":6000,"receive_amt":5000,"payment_amt":7000,"outstanding_amt":4000,"phone_no":"BBBBBBB","agent_code":"A003 "},{"cust_code":"C00001","cust_name":"Micheal","cust_city":"New York
","working_area":"New York","cust_country":"USA","grade":2,"opening_amt":3000,"receive_amt":5000,"payment_amt":2000,"outstanding_amt":6000,"phone_no":"CCCCCCC","agent_code":"A008 "},{"cust_code":"C00020","cust_name":"Albert","cust_city":"New York
","working_area":"New York","cust_country":"USA","grade":3,"opening_amt":5000,"receive_amt":7000,"payment_amt":6000,"outstanding_amt":6000,"phone_no":"BBBBSBB","agent_code":"A008 "},{"cust_code":"C00025","cust_name":"Ravindran","cust_city":"Bangalore ","working_area":"Bangalore","cust_country":"India","grade":2,"opening_amt":5000,"receive_amt":7000,"payment_amt":4000,"outstanding_amt":8000,"phone_no":"AVAVAVA","agent_code":"A011 "},{"cust_code":"C00015","cust_name":"Stuart","cust_city":"London
","working_area":"London","cust_country":"UK","grade":1,"opening_amt":6000,"receive_amt":8000,"payment_amt":3000,"outstanding_amt":11000,"phone_no":"GFSGERS","agent_code":"A003 "}],"hasMore":false,"limit":25,"offset":0,"count":5,"links":[{"rel":"self","href":"http://localhost:9000/ords/demo/customers/getAll/"},{"rel":"describedby","href":"http://localhost:9000/ords/demo/metadata-catalog/customers/getAll/"},{"rel":"first","href":"http://localhost:9000/ords/demo/customers/getAll/"}]}
所以我想知道是否有办法分解项目部分并使用 anguler 将其放入表格中。
我尝试在我的 ts 文件中使用这种方式:
http.get('http://localhost:9000/ords/demo/customers/getAll/')
.subscribe(data => this.items = data);
但是我一直收到这个错误:
Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed
你想要的数组在items
属性所以你必须做
http.get('http://localhost:9000/ords/demo/customers/getAll/')
.subscribe(data => this.items = data.items);