如何创建名为Bill
的类,该类具有简单属性,如string and number
&另一个属性是另一个类Customer
的Object
。对象中的角2对象
我想比尔json
对象bill: Bill
这个样子的:
bill = {
id: "",
usage : "",
total : "0",
customer : {
customerFirstname :"",
customerLastname :"",
}
}
这个对象是AngularJS
正确的,但不是在Angular2
。
Customer类:
export class Customer{
customerFirstname: string;
customerLastname: string;
constructor(){
}
}
和比尔类:
import {Customer} from '../customer/customer.model';
export class Bill {
id : string ;
usage: string;
total: number;
customer : Customer;
constructor(){
}
}
我已经延长,但通过显示'{{bill.customer.customerFirstname}}' – Manu
'{{bill.customerFirstname}}''''''''''''''你只需要做到这一点就不会在'html'中工作。 @Manu – User1911
@Manu更新了我的示例。 – User1911