<ion-header>
  <ion-toolbar>
    <ion-title>
      {{post ? 'Post Details' : 'Add Post'}}
    </ion-title>
    <ion-buttons start>
      <button ion-button (click)="dismiss()">
        <span ion-text color="primary" showWhen="ios,core">Cancel</span>
        <ion-icon name="md-close" showWhen="android,windows"></ion-icon>
      </button>
    </ion-buttons>
  </ion-toolbar>
</ion-header>
<ion-content padding>
  <form #postForm="ngForm" (ngSubmit)="save(postForm.value)">
    <input type="hidden" name="href" [(ngModel)]="post.href">
    <ion-row>
      <ion-col>
        <ion-list inset>
          <ion-item>
            <ion-input placeholder="Post Message" name="name" type="text"
                       required [(ngModel)]="post.text" #name></ion-input>
          </ion-item>
        </ion-list>
      </ion-col>
    </ion-row>
    <ion-row>
      <ion-col *ngIf="post" text-center>
        <img src="{{post.giphyUrl}}">
      </ion-col>
    </ion-row>
    <ion-row>
      <ion-col>
        <div *ngIf="error" class="alert alert-danger">{{error}}</div>
        <button ion-button color="primary" full type="submit"
                [disabled]="!postForm.form.valid">Save</button>
      </ion-col>
    </ion-row>
  </form>
</ion-content>
