src/pages/home/home.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { constructor(public navCtrl: NavController) { let myData = { "Distance": 10, "lat": 12, "lng": 20 } console.log("myData " + myData); console.log(" Distance " + myData.Distance); console.log(" lat " + myData.lat); console.log(" lng " + myData.lng); } } |
บรรทัดที่ 12-16: กำหนดค่าให้ตัวแปร myData
บรรทัดที่ 18: จะไม่เห็นค่า เห็นเป็น [object Object]
บรรทัดที่ 19-21: จะเห็นค่าที่ต้องการ