Guest User

Untitled

a guest
Jan 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { NgZone } from '@angular/core';
  3. import { NavController } from 'ionic-angular';
  4. import { Tracker } from 'meteor/tracker';
  5.  
  6. // Import this module
  7. import { Meteor } from 'meteor/meteor';
  8.  
  9. @Component({
  10. selector: 'page-home',
  11. templateUrl: 'home.html'
  12. })
  13. export class HomePage {
  14.  
  15. private currentName: string;
  16. private serverResults: string;
  17. private currentUser: string;
  18. autorunComputation: Tracker.Computation;
  19.  
  20. constructor(public navCtrl: NavController, private zone: NgZone) {
  21.  
  22. this._initAutorun();
  23.  
  24. }
  25.  
  26. _initAutorun(): void {
  27. this.autorunComputation = Tracker.autorun(() => {
  28.  
  29. this.zone.run(() => {
  30.  
  31.  
  32. if (Meteor.user()) {
  33. this.currentUser = Meteor.user().profile.name
  34.  
  35. }
  36. else {
  37. this.currentUser = "Not Logged In!"
  38.  
  39. }
  40.  
  41. })
  42. });
  43. }
  44.  
  45. private openPage(s: string) {
  46. this.navCtrl.push(s);
  47. }
  48.  
  49. private openProtected(s: string) {
  50. if (Meteor.user()) {
  51. this.navCtrl.push(s)
  52. }
  53. }
  54.  
  55.  
  56.  
  57. callServer(): void {
  58. // Call Meteor
  59. Meteor.call('cutenessLevel', this.currentName, (error, results) => {
  60.  
  61. if (!error) {
  62. this.serverResults = results;
  63. }
  64.  
  65. else {
  66. console.log(error);
  67. }
  68.  
  69. });
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment