如何創建名爲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