import { Component, ViewEncapsulation } from '@angular/core'; import { ionicBootstrap, ItemSliding, NavController, Toast, reorderArray } from 'ionic-angular'; @Component({ templateUrl: 'main.html', encapsulation: ViewEncapsulation.None }) class ApiDemoPage { chats: any[]; editButton: string = 'Reorder'; editing: boolean = false; constructor(private nav: NavController) { this.chats = [ { img: './avatar-cher.png', name: 'Cher', message: 'Ugh. As if.', time: '9:38 pm' }, { img: './avatar-dionne.png', name: 'Dionne', message: 'Mr. Hall was way harsh.', time: '8:59 pm' }, { img: './avatar-murray.png', name: 'Murray', message: 'Excuse me, "Ms. Dione."', time: 'Wed' }, { img: './avatar-cher.png', name: 'Cher', message: 'Ugh. As if.', time: '9:38 pm' }, { img: './avatar-dionne.png', name: 'Dionne', message: 'Mr. Hall was way harsh.', time: '8:59 pm' }, { img: './avatar-murray.png', name: 'Murray', message: 'Excuse me, "Ms. Dione."', time: 'Wed' }, { img: './avatar-cher.png', name: 'Cher', message: 'Ugh. As if.', time: '9:38 pm' }, { img: './avatar-dionne.png', name: 'Dionne', message: 'Mr. Hall was way harsh.', time: '8:59 pm' }, { img: './avatar-murray.png', name: 'Murray', message: 'Excuse me, "Ms. Dione."', time: 'Wed' }]; } toggleEdit() { this.editing = !this.editing; if (this.editing) { this.editButton = 'Done'; } else { this.editButton = 'Reorder'; } } reorderData(indexes: any) { this.chats = reorderArray(this.chats, indexes); } } @Component({ template: '' }) class ApiDemoApp { root = ApiDemoPage; } ionicBootstrap(ApiDemoApp);