Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { Data } from '../../providers/data';
  3. import { NewListPage } from '../new-list/new-list';
  4. import { NavController } from 'ionic-angular';
  5.  
  6. @Component({
  7. selector: 'page-page1',
  8. templateUrl: 'page1.html',
  9.  
  10. })
  11.  
  12. export class Page1 {
  13. public list: any[] = [];
  14.  
  15. constructor(public navCtrl: NavController, private _data: Data) {
  16. console.log('Page1BEFORE');
  17.  
  18. let that = this;
  19. this._data.list.subscribe((data) => {that.list.push(data);}, (err) => {console.error(err);});
  20. }
  21. newList() {
  22. console.log('NEWLIST1');
  23. this.navCtrl.push(NewListPage);
  24. }
  25.  
  26. }
  27.  
  28. <ion-app>
  29. <ion-header>
  30. <ion-navbar>
  31. <button ion-button menuToggle>
  32. <ion-icon name="menu"></ion-icon>
  33. </button>
  34. <ion-title>Page One</ion-title>
  35. <ion-buttons end>
  36. <ion-icon ios="ios-contact" md="md-contact"></ion-icon>
  37. </ion-buttons>
  38. </ion-navbar>
  39. </ion-header>
  40.  
  41.  
  42. <ion-content class="grid-basic-page">
  43. <ion-col width-100><progress class="progressBar" max="100" value="80"></progress></ion-col>
  44. <ion-row>
  45. <ion-col width-50><div>col</div></ion-col>
  46. <ion-col width-50><div>col</div></ion-col>
  47. </ion-row>
  48. <ion-row>
  49. <ion-col width-50><div>col</div></ion-col>
  50. <ion-col width-50><div>col</div></ion-col>
  51. </ion-row>
  52. <ion-row>
  53. <ion-col width-50><div>col</div></ion-col>
  54. <ion-col width-50><div>col</div></ion-col>
  55. </ion-row>
  56. <ion-list *ngIf="list">
  57. <ion-item *ngFor="let item of list">
  58. <ion-label>{{item.title}}</ion-label>
  59. </ion-item>
  60. </ion-list>
  61. <p *ngIf="!list"> No Lists </p>
  62. <button fab fab-bottom fab-right (click)="newList()"> New </button>
  63. </ion-content>
  64. </ion-app>
  65.  
  66. import { Component, ViewChild } from '@angular/core';
  67. import { Nav, Platform } from 'ionic-angular';
  68. import { StatusBar, Splashscreen } from 'ionic-native';
  69.  
  70. import { Page1 } from '../pages/page1/page1';
  71. import { Page2 } from '../pages/page2/page2';
  72. import { Data } from '../providers/data';
  73.  
  74. @Component({
  75. templateUrl: 'app.html',
  76. providers: [Data],
  77. })
  78. export class MyApp {
  79. @ViewChild(Nav) nav: Nav;
  80.  
  81. rootPage: any = Page1;
  82.  
  83. pages: Array<{title: string, component: any}>;
  84.  
  85. constructor(public platform: Platform) {
  86. console.log('PreAPP');
  87. this.initializeApp();
  88. console.log('PostApp');
  89.  
  90. // used for an example of ngFor and navigation
  91. this.pages = [
  92. { title: 'Page One', component: Page1 },
  93. { title: 'Page Two', component: Page2 }
  94. ];
  95. console.log('pages');
  96.  
  97. }
  98.  
  99. initializeApp() {
  100. console.log('APP');
  101. this.platform.ready().then(() => {
  102. // Okay, so the platform is ready and our plugins are available.
  103. // Here you can do any higher level native things you might need.
  104. StatusBar.styleDefault();
  105. Splashscreen.hide();
  106. });
  107. }
  108.  
  109. openPage(page) {
  110. console.log('OpenPAGE');
  111.  
  112. // Reset the content nav to have just this page
  113. // we wouldn't want the back button to show in this scenario
  114. this.nav.setRoot(page.component);
  115. }
  116. }
  117.  
  118. <ion-menu [content]="content">
  119. <ion-header>
  120. <ion-toolbar>
  121. <ion-title>Menu</ion-title>
  122. </ion-toolbar>
  123. </ion-header>
  124.  
  125. <ion-content>
  126. <ion-list>
  127. <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
  128. {{ p.title }}
  129. </button>
  130. </ion-list>
  131. </ion-content>
  132.  
  133. </ion-menu>
  134.  
  135. <!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
  136. <ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement