Ionic: การใช้งานตัวแปร string

สร้างตัวแปรชื่อ name และแสดงค่าของตัวแปร name
list

แก้ไขไฟล์ src/pages/home/home.ts

[code]
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

name: string;

constructor(public navCtrl: NavController) {
this.name = ‘Jack’;
}

}
[/code]

ประกาศตัวแปร name เป็นชนิด string

แก้ไขไฟล์ src/pages/home/home.html

[code]
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding>
Hello {{name}}
</ion-content>
[/code]

นำตัวแปร name มาแสดงผล

[BOXMOBILEDEV] Ionic 3 EP2 : ตัวแปรต่างๆและการแสดงผล