angular - Component variable in template inaccessible -
i have variable got api. want show in template (in same component) shows me this:
[object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] [object object] // // // // // // // //
this try in template:
<div *ngfor="let item of airport"> <div *ngfor="let of item"> {{ }} </div> </div>
but when try print variable console.log
, value expected:
// code console.log(this.airport); console.log(this.airport[0]); console.log(this.airport[0][0]); console.log(this.airport[0][0]['airportcode']); console.log(typeof this.airport[0][0]); // output array [ array[51], array[47] ] array [ object, object, object, object, object, object, object, object, object, object, 41 more… ] object { airlinecode: "jt*", airlinelogourlpng: "http://d3brl4nqahsb3e.cloudfront.ne…", airlinelogourlsvg: "http://d3brl4nqahsb3e.cloudfront.ne…", airlinename: "lion air", airportcode: "bpn", airportname: "sultan aji muhamad sulaiman airport", city: "balikpapan", currentdate: "11/04/2016", currentgatedate: "11/04/2016", currentgatetime: "19:05", 31 more… } bpn object
is there wrong code? or maybe there don't know in angular2?
as referring object, object contains properties. have use object.property
syntax follow,
{{ i.airlinecode })
or
{{ i.airlinelogourlpng }}
and on.
Comments
Post a Comment