/
app.module.ts
857 lines (741 loc) · 22.1 KB
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
import { NgModule, Component, ViewChild } from '@angular/core';
import { App, AlertController, Content, DeepLinkConfig, IonicApp, IonicModule, NavController, NavParams, Tabs, Tab, ModalController, ViewController } from '../../../../../ionic-angular';
@Component({
selector: 'my-cmp2',
template: `<span style="color:green">{{value}}</span>`
})
export class MyCmpTest2 {
value: string = 'Test Failed';
}
@Component({
selector: 'my-cmp',
template: `<my-cmp2></my-cmp2> <span style="color:green">{{value}}</span>`
})
export class MyCmpTest {
@ViewChild(MyCmpTest2) _label: MyCmpTest2;
label: MyCmpTest2;
value: string = 'Test Failed';
ngOnInit() {
this.label = this._label;
}
}
@Component({
template: `
<ion-header>
<ion-navbar>
<ion-title>{{title}}</ion-title>
<ion-buttons start>
<button ion-button icon-only><ion-icon name="star"></ion-icon></button>
</ion-buttons>
<ion-buttons end>
<button ion-button>S1g</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<div padding>
<p>ionViewCanEnter ({{called.ionViewCanEnter}})</p>
<p>ionViewCanLeave ({{called.ionViewCanLeave}})</p>
<p>ionViewWillLoad ({{called.ionViewWillLoad}})</p>
<p>ionViewDidLoad ({{called.ionViewDidLoad}})</p>
<p>ionViewWillEnter ({{called.ionViewWillEnter}})</p>
<p>ionViewDidEnter ({{called.ionViewDidEnter}})</p>
<p>ionViewWillLeave ({{called.ionViewWillLeave}})</p>
<p>ionViewDidLeave ({{called.ionViewDidLeave}})</p>
<my-cmp></my-cmp>
</div>
<ion-list>
<ion-list-header>
{{title}}
</ion-list-header>
<ion-item class="e2eFrom1To2" (click)="pushFullPage()">Push to FullPage</ion-item>
<button ion-item (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button>
<button ion-item (click)="pushRedirect()">Push to Redirect</button>
<button ion-item (click)="pushTabsPage()">Push to Tabs Page</button>
<button ion-item (click)="pushAnother()">Push to AnotherPage</button>
<ion-item>
<ion-label>Text Input</ion-label>
<ion-textarea></ion-textarea>
</ion-item>
<button ion-item [navPush]="pushPage">Push FullPage w/ [navPush]="pushPage"</button>
<button ion-item [navPush]="pushPage" [navParams]="{id:40}">Push w/ [navPush] and [navParams]</button>
<button ion-item [navPush]="firstPage">Push w/ [navPush] and firstPage</button>
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
<button ion-item (click)="pop()">Pop</button>
<ion-item>
<ion-label>Toggle Can Leave</ion-label>
<ion-toggle (click)="canLeave = !canLeave"></ion-toggle>
</ion-item>
<button ion-item (click)="viewDismiss()">View Dismiss</button>
<button ion-item (click)="quickPush()">New push during transition</button>
<button ion-item (click)="quickPop()">New pop during transition</button>
<button ion-item (click)="reload()">Reload</button>
<button ion-item (click)="scrollToBottom()">Scroll to bottom</button>
<button ion-item *ngFor="let i of pages" (click)="pushPrimaryHeaderPage()">Page {{i}}</button>
<button ion-item (click)="content.scrollToTop()">Scroll to top</button>
</ion-list>
</ion-content>`
})
export class FirstPage {
pushPage = FullPage;
firstPage = FirstPage;
title = 'First Page';
pages: Array<number> = [];
@ViewChild(Content) content: Content;
@ViewChild(MyCmpTest) myCmp: MyCmpTest;
canLeave = true;
called: any;
constructor(
public navCtrl: NavController,
public viewCtrl: ViewController,
public alertCtrl: AlertController
) {
this.called = {
ionViewCanEnter: 0,
ionViewCanLeave: 0,
ionViewWillLoad: 0,
ionViewDidLoad: 0,
ionViewWillEnter: 0,
ionViewDidEnter: 0,
ionViewWillLeave: 0,
ionViewDidLeave: 0
};
}
ionViewWillLoad() {
console.log('ionViewWillLoad, FirstPage', this.viewCtrl.id);
this.called.ionViewWillLoad++;
}
ionViewDidLoad() {
console.log('ionViewDidLoad, FirstPage');
for (var i = 1; i <= 50; i++) {
this.pages.push(i);
}
if (!this.myCmp || !this.content || !this.myCmp.label) {
throw new Error('children are not loaded');
}
this.myCmp.value = '👍 self test passed!';
this.myCmp.label.value = '👍 children test passed!';
this.called.ionViewDidLoad++;
}
ionViewWillEnter() {
console.log('ionViewWillEnter, FirstPage', this.viewCtrl.id);
this.called.ionViewWillEnter++;
}
ionViewDidEnter() {
console.log('ionViewDidEnter, FirstPage', this.viewCtrl.id);
this.called.ionViewDidEnter++;
}
ionViewWillLeave() {
console.log('ionViewWillLeave, FirstPage', this.viewCtrl.id);
this.called.ionViewWillLeave++;
}
ionViewDidLeave() {
console.log('ionViewDidLeave, FirstPage', this.viewCtrl.id);
this.called.ionViewDidLeave++;
}
ionViewWillUnload() {
console.log('ionViewWillUnload, FirstPage', this.viewCtrl.id);
this.called.ionViewWillUnload++;
}
ionViewCanLeave() {
if (this.canLeave) {
return true;
}
let alert = this.alertCtrl.create();
alert.setMessage('You can check-out any time you like, but you can never leave.');
alert.addButton({ text: 'Umm, ok', role: 'cancel', });
alert.present();
this.called.ionViewCanLeave++;
return false;
}
ionViewCanEnter() {
this.called.ionViewCanEnter++;
return true;
}
setPages() {
let items = [
{ page: PrimaryHeaderPage }
];
this.navCtrl.setPages(items);
}
setRoot() {
this.navCtrl.setRoot(PrimaryHeaderPage);
}
pushPrimaryHeaderPage() {
this.navCtrl.push(PrimaryHeaderPage, null, {
animate: true,
animation: 'ios-transition'
}).then(() => { }, (rejectReason: string) => {
});
}
pushRedirect() {
this.navCtrl.push(RedirectPage).then(() => { }, (rejectReason: string) => {
});
}
pushFullPage() {
this.navCtrl.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] }, {
animate: true,
animation: 'md-transition'
}).catch(() => {
});
}
pushAnother() {
this.navCtrl.push(AnotherPage, null, {
animate: true,
animation: 'wp-transition'
}).catch(() => {
});
}
pushTabsPage() {
this.navCtrl.push(TabsPage).catch(() => {
});
}
quickPush() {
this.navCtrl.push(AnotherPage).catch(() => {
});
setTimeout(() => {
this.navCtrl.push(PrimaryHeaderPage).catch(() => {
});
}, 150);
}
quickPop() {
this.navCtrl.push(AnotherPage).catch(() => {
});
setTimeout(() => {
this.navCtrl.remove(1, 1).catch(() => {
});
}, 250);
}
pop() {
this.navCtrl.pop().catch(() => {});
}
viewDismiss() {
this.viewCtrl.dismiss();
}
reload() {
window.location.reload();
}
scrollToTop() {
this.content.scrollToTop();
}
scrollToBottom() {
this.content.scrollToBottom(1000);
}
}
@Component({template: '<ion-content></ion-content>'})
export class RedirectPage {
constructor(public navCtrl: NavController) { }
ionViewDidEnter() {
this.navCtrl.push(PrimaryHeaderPage);
}
}
@Component({
template: `
<ion-content padding>
<h1>Full page</h1>
<p>This page does not have a nav bar!</p>
<p><button ion-button (click)="navCtrl.pop()">Pop</button></p>
<p><button ion-button class="e2eFrom2To3" (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button></p>
<p><button ion-button (click)="pushAnother()">Push to AnotherPage</button></p>
<p><button ion-button (click)="pushFirstPage()">Push to FirstPage</button></p>
<p><button ion-button class="e2eFrom2To1" navPop>Pop with NavPop (Go back to 1st)</button></p>
<p><button ion-button (click)="setPages()">setPages() (Go to PrimaryHeaderPage, FirstPage 1st in history)</button></p>
<p><button ion-button (click)="presentAlert()">Present Alert</button></p>
</ion-content>
`
})
export class FullPage {
constructor(
public navCtrl: NavController,
public viewCtrl: ViewController,
public app: App,
public alertCtrl: AlertController,
public params: NavParams
) {}
ionViewDidLoad() {
console.log('ionViewDidLoad, FullPage', this.viewCtrl.id);
}
ionViewWillEnter() {
console.log('ionViewWillEnter, FullPage', this.viewCtrl.id);
}
ionViewDidEnter() {
console.log('ionViewDidEnter, FullPage', this.viewCtrl.id);
}
ionViewWillLeave() {
console.log('ionViewWillLeave, FullPage', this.viewCtrl.id);
}
ionViewDidLeave() {
console.log('ionViewDidLeave, FullPage', this.viewCtrl.id);
}
ionViewWillUnload() {
console.log('ionViewWillUnload, FullPage', this.viewCtrl.id);
}
setPages() {
let items = [
{ page: FirstPage },
{ page: PrimaryHeaderPage }
];
this.navCtrl.setPages(items);
}
pushPrimaryHeaderPage() {
this.navCtrl.push(PrimaryHeaderPage);
}
pushAnother() {
this.navCtrl.push(AnotherPage);
}
pushFirstPage() {
this.navCtrl.push(FirstPage);
}
presentAlert() {
let alert = this.alertCtrl.create();
alert.setTitle('Hello Alert');
alert.setMessage('Dismiss this alert, then pop one page');
alert.addButton({
text: 'Dismiss',
role: 'cancel',
handler: () => {
// overlays are added and removed from the app root's portal
// in the example below, alert.dismiss() dismisses the alert
// from the app root portal, and once it's done transitioning out,
// this the active page is popped from the nav
alert.dismiss().then(() => {
this.navCtrl.pop();
});
// by default an alert will dismiss itself
// however, we don't want to use the default
// but rather fire off our own pop navigation
// return false so it doesn't pop automatically
return false;
}
});
alert.present();
}
}
@Component({
template: `
<ion-header>
<ion-navbar color="primary">
<ion-title>Primary Color Page Header</ion-title>
<ion-buttons end>
<button ion-button>S1g</button>
</ion-buttons>
</ion-navbar>
<ion-toolbar>
<ion-title>{{subheader}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding fullscreen>
<p><button ion-button class="e2eFrom3To2" (click)="navCtrl.pop()">Pop</button></p>
<p><button ion-button (click)="pushAnother()">Push to AnotherPage</button></p>
<p><button ion-button (click)="pushFullPage()">Push to FullPage</button></p>
<p><button ion-button (click)="setRoot()">setRoot(AnotherPage)</button></p>
<p><button ion-button (click)="navCtrl.popToRoot()">Pop to root</button></p>
<p><button ion-button id="insert" (click)="insert()">Insert first page into history before this</button></p>
<p><button ion-button id="remove" (click)="removeSecond()">Remove second page in history</button></p>
<div class="yellow"><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div></div>
<button ion-button ion-fixed no-margin color="danger" (click)="presentAlert()">fixed button (alert)</button>
<div ion-fixed style="position: absolute; pointer-events: none; top:0; bottom:0; right:0; width:50%; background: rgba(0,0,0,0.5);"></div>
</ion-content>
<ion-footer>
<ion-toolbar>
I'm a sub footer!
</ion-toolbar>
<ion-toolbar>
<ion-title>Footer</ion-title>
</ion-toolbar>
</ion-footer>
`
})
export class PrimaryHeaderPage {
subheader: string;
constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public viewCtrl: ViewController
) {}
ionViewDidLoad() {
console.log('ionViewDidLoad, PrimaryHeaderPage', this.viewCtrl.id);
}
ionViewWillEnter() {
console.log('ionViewWillEnter, PrimaryHeaderPage', this.viewCtrl.id);
this.viewCtrl.setBackButtonText('Previous');
this.subheader = 'I\'m a sub header!';
}
ionViewDidEnter() {
console.log('ionViewDidEnter, PrimaryHeaderPage', this.viewCtrl.id);
}
ionViewWillLeave() {
console.log('ionViewWillLeave, PrimaryHeaderPage', this.viewCtrl.id);
}
ionViewDidLeave() {
console.log('ionViewDidLeave, PrimaryHeaderPage', this.viewCtrl.id);
}
ionViewWillUnload() {
console.log('ionViewWillUnload, PrimaryHeaderPage', this.viewCtrl.id);
}
pushAnother() {
this.navCtrl.push(AnotherPage);
}
pushFullPage() {
this.navCtrl.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] });
}
insert() {
this.navCtrl.insert(2, FirstPage);
}
removeSecond() {
this.navCtrl.remove(1);
}
setRoot() {
this.navCtrl.setRoot(AnotherPage);
}
presentAlert() {
let alert = this.alertCtrl.create();
alert.setTitle('Hello Alert');
alert.addButton({ text: 'Dismiss', role: 'cancel', });
alert.present();
}
}
@Component({
template: `
<ion-header>
<ion-navbar hideBackButton>
<ion-title>Another Page Header</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-toolbar>
I'm a sub header in the content!
</ion-toolbar>
<ion-list>
<ion-item>
<ion-label>Text Input</ion-label>
<ion-textarea></ion-textarea>
</ion-item>
<ion-item>Back button hidden w/ <code>ion-navbar hideBackButton</code></ion-item>
<button ion-item (click)="navCtrl.pop()">Pop</button>
<button ion-item (click)="pushFullPage()">Push to FullPage</button>
<button ion-item (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button>
<button ion-item (click)="pushFirstPage()">Push to FirstPage</button>
<button ion-item (click)="setRoot()">setRoot(FirstPage)</button>
<button ion-item (click)="toggleBackButton()">Toggle hideBackButton</button>
<button ion-item (click)="setBackButtonText()">Set Back Button Text</button>
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>
</ion-list>
<ion-toolbar>
I'm a sub footer in the content!
</ion-toolbar>
<ion-toolbar>
And I'm a sub footer in the content too!
</ion-toolbar>
</ion-content>
<ion-footer>
<ion-toolbar>
Another Page Footer
</ion-toolbar>
</ion-footer>
`
})
export class AnotherPage {
bbHideToggleVal = false;
bbCount = 0;
constructor(
public navCtrl: NavController,
public viewCtrl: ViewController
) { }
ionViewDidLoad() {
console.log('ionViewDidLoad, AnotherPage', this.viewCtrl.id);
}
ionViewWillEnter() {
console.log('ionViewWillEnter, AnotherPage', this.viewCtrl.id);
}
ionViewDidEnter() {
console.log('ionViewDidEnter, AnotherPage', this.viewCtrl.id);
}
ionViewWillLeave() {
console.log('ionViewWillLeave, AnotherPage', this.viewCtrl.id);
}
ionViewDidLeave() {
console.log('ionViewDidLeave, AnotherPage', this.viewCtrl.id);
}
ionViewWillUnload() {
console.log('ionViewWillUnload, AnotherPage', this.viewCtrl.id);
}
pushFullPage() {
this.navCtrl.push(FullPage);
}
pushPrimaryHeaderPage() {
this.navCtrl.push(PrimaryHeaderPage);
}
pushFirstPage() {
this.navCtrl.push(FirstPage);
}
setRoot() {
this.navCtrl.setRoot(FirstPage);
}
toggleBackButton() {
this.bbHideToggleVal = !this.bbHideToggleVal;
this.viewCtrl.showBackButton(this.bbHideToggleVal);
}
setBackButtonText() {
let backButtonText = 'Messages';
if (this.bbCount > 0) {
backButtonText += ` (${this.bbCount})`;
}
this.viewCtrl.setBackButtonText(backButtonText);
++this.bbCount;
}
}
//
// Tab 1
//
@Component({
template: `
<ion-header>
<ion-navbar>
<ion-title>Heart</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-list-header>
Tab 1
</ion-list-header>
<ion-item>
<button ion-button (click)="goBack()">Back</button>
</ion-item>
<ion-item (click)="goTo()" *ngFor="let i of items">Item {{i}} {{i}} {{i}} {{i}}</ion-item>
</ion-list>
<p>
<button ion-button (click)="selectPrevious()">Select Previous Tab</button>
</p>
<p>
<button ion-button (click)="appNavPop()">App Nav Pop</button>
</p>
</ion-content>
`
})
export class Tab1 {
items: any[] = [];
constructor(private tabs: Tabs, private app: App, private nav: NavController) {
for (var i = 1; i <= 250; i++) {
this.items.push(i);
}
}
goBack() {
this.nav.parent.parent.pop();
}
goTo() {
this.nav.push(TabItemPage);
}
selectPrevious() {
this.tabs.select(this.tabs.previousTab());
}
appNavPop() {
this.app.navPop();
}
}
//
// Tab 2
//
@Component({
template: `
<ion-header>
<ion-navbar>
<ion-title>Schedule</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item-sliding *ngFor="let session of sessions" #slidingItem>
<ion-item>
<h3>{{session.name}} {{session.name}} {{session.name}}</h3>
<p>{{session.location}} {{session.location}} {{session.location}}</p>
</ion-item>
<ion-item-options>
<button ion-button color="primary">Speaker<br>Info</button>
<button ion-button color="secondary">Add to<br>Favorites</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
<p>
<button ion-button (click)="selectPrevious()">Select Previous Tab</button>
</p>
<p>
<button ion-button (click)="appNavPop()">App Nav Pop</button>
</p>
</ion-content>
`
})
export class Tab2 {
sessions: any[] = [];
constructor(private tabs: Tabs, private app: App) {
for (var i = 1; i <= 250; i++) {
this.sessions.push({
name: 'Name ' + i,
location: 'Location: ' + i
});
}
}
selectPrevious() {
this.tabs.select(this.tabs.previousTab());
}
appNavPop() {
this.app.navPop();
}
}
//
// Tab 3
//
@Component({
template: `
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Stopwatch</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h2>Tab 3</h2>
<p>
<button ion-button (click)="presentAlert()">Present Alert</button>
<button ion-button (click)="presentModal()">Present Modal</button>
</p>
<p>
<button ion-button (click)="selectPrevious()">Select Previous Tab</button>
</p>
<p>
<button ion-button (click)="appNavPop()">App Nav Pop</button>
</p>
</ion-content>
`
})
export class Tab3 {
constructor(private alertCtrl: AlertController, private modalCtrl: ModalController, private tabs: Tabs, private app: App) {}
presentAlert() {
let alert = this.alertCtrl.create({
title: 'Alert Title!',
buttons: ['Dismiss']
});
alert.present();
}
presentModal() {
// this.modalCtrl.create(MyModal).present();
}
selectPrevious() {
this.tabs.select(this.tabs.previousTab());
}
appNavPop() {
this.app.navPop();
}
}
@Component({
template: `
<ion-menu [content]="content">
<ion-header>
<ion-toolbar color="secondary">
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item menuClose detail-none>
Close Menu
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-tabs #content (ionChange)="onChange($event)">
<ion-tab tabUrlPath="plain" tabTitle="Plain List" tabIcon="star" [root]="root1" (ionSelect)="onSelect($event)"></ion-tab>
<ion-tab tabTitle="Schedule" tabIcon="globe" [root]="root2"></ion-tab>
<ion-tab tabTitle="Stopwatch" tabIcon="logo-facebook" [root]="root3"></ion-tab>
<ion-tab tabTitle="Messages" tabIcon="chatboxes" [root]="root1"></ion-tab>
<ion-tab tabTitle="My Profile" tabIcon="person" [root]="root2"></ion-tab>
</ion-tabs>
`
})
export class TabsPage {
root1 = Tab1;
root2 = Tab2;
root3 = Tab3;
onChange(ev: Tab) {
console.log('Changed tab', ev);
}
onSelect(ev: Tab) {
console.log('Selected tab', ev);
}
}
@Component({
template: `
<ion-header>
<ion-navbar>
<ion-title>Tab Item</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<h2>Hello moto</h2>
</ion-content>
`
})
export class TabItemPage {
items: any[] = [];
constructor(private tabs: Tabs, private app: App) {
}
}
@Component({
template: `<ion-nav [root]="root"></ion-nav>`
})
export class E2EApp {
root = FirstPage;
}
export const deepLinkConfig: DeepLinkConfig = {
links: [
{ component: FirstPage, name: 'first-page' },
{ component: AnotherPage, name: 'another-page' },
{ component: MyCmpTest, name: 'tab1-page1' },
{ component: FullPage, name: 'full-page', defaultHistory: ['first-page', 'another-page'] },
{ component: PrimaryHeaderPage, name: 'primary-header-page', defaultHistory: ['first-page', 'full-page'] },
{ component: Tabs, name: 'tabs' },
{ component: Tab1, name: 'tab1' },
{ component: TabItemPage, name: 'item' }
]
};
@NgModule({
declarations: [
E2EApp,
FirstPage,
RedirectPage,
AnotherPage,
MyCmpTest,
MyCmpTest2,
FullPage,
PrimaryHeaderPage,
TabsPage,
Tab1,
Tab2,
Tab3,
TabItemPage
],
imports: [
IonicModule.forRoot(E2EApp, {
swipeBackEnabled: true
}, deepLinkConfig)
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
FirstPage,
RedirectPage,
AnotherPage,
FullPage,
PrimaryHeaderPage,
TabsPage,
Tab1,
Tab2,
Tab3,
TabItemPage
]
})
export class AppModule {}