본문 바로가기

Web/Ionic

[Ionic] 디자인 컴포넌트와 변수의 연결 – ngModel, ngIf

action-sheet.html

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Action Sheet Page</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <input type="text" [(ngModel)]="name">
  <p>Hello, {{name}}</p>
  <p *ngIf="name">Welcome</p>
  <button ion-button block (click)="presentActionSheet()">
    Show Action Sheet
  </button>
</ion-content>


action-sheet.ts

import { Component } from '@angular/core';
import { ActionSheetController } from 'ionic-angular';

@Component({
    templateUrl: 'action-sheet.html'
})
export class ActionSheetPage {
    name: string = "";

    constructor(public actionSheetCtrl: ActionSheetController) {
    
    }

    presentActionSheet() {
        let actionSheet = this.actionSheetCtrl.create({
            title: 'action sheet demo',
            buttons: [
                {
                    text: 'Delete',
                    role: 'destructive',
                    handler: () => {

                    }
                },
                {
                    text: 'button',
                    handler: () => {

                    }
                },
                {
                    text: 'cancel',
                    role: 'cancel',
                    handler: () => {
                        
                    }
                }
            ]
        });
        actionSheet.present();
    }
}


'Web > Ionic' 카테고리의 다른 글

[Ionic] 프로젝트 폴더구조  (0) 2017.03.29
[Ionic] Components Cards  (0) 2017.03.28
[Ionic] Components Buttons  (0) 2017.03.28
[Ionic] Components Alerts  (0) 2017.03.27
[Ionic] Components Action Sheets  (0) 2017.03.23