我目前正在构建一个带有Netbeans RESTful后端的angularJS / typescript web应用程序。我为供应商设置了打字稿界面,如下所示:
if x in d:
当我打电话给我的休息服务从我的JavaDB撤回所有供应商时,它正在撤回以与我的界面完全不同的方案命名的JSON,并且为了使我的角度指令起作用,我必须引用这个JSON的命名方案反而导致事情破坏:
interface Vendor {
vendorno: number,
name: string,
address1: string,
city: string,
province: string,
postalcode: string,
phone: string,
vendortype: string,
email: string;
}
为了在我的部分表格中显示此供应商数据,我将不得不使用以下角度绑定:
[{"vendorAddress":"543 Sycamore Ave","vendorCity":"Toronto","vendorEmail":"bb@depot.ca","vendorName":"Big Bills Depot","vendorNo":1,"vendorPhone":"(999) 555-5555","vendorPostalcode":"N1P1N5","vendorProvince":"ON","vendorType":"Trusted"},
{"vendorAddress":"628 Richmond Street","vendorCity":"London","vendorEmail":"abc@supply.ca","vendorName":"ABC Supply Co.","vendorNo":2,"vendorPhone":"(519) 123-4567","vendorPostalcode":"N6C1L7","vendorProvince":"ON","vendorType":"Trusted"},
{"vendorAddress":"123 Main Boulevard","vendorCity":"Burlington","vendorEmail":"gs@shack.net","vendorName":"Gadget Shack","vendorNo":3,"vendorPhone":"(613) 444-3423","vendorPostalcode":"N3X5S2","vendorProvince":"ON","vendorType":"Unknown"}]
是否有任何理由让angularJS或我的Java REST服务自动重命名我返回的JSON以获得这些属性名称?
答案 0 :(得分:0)
是否有任何理由让angularJS或我的Java REST服务自动重命名我返回的JSON以具有这些属性名称
不是棱角分明的。它可能是Java REST服务。
一个选项是更新接口以匹配服务器返回的内容:
interface Vendor {
vendorNo: number;
vendorName: string;
// so on ...
}