Skip to content

Instantly share code, notes, and snippets.

@jayserdny
Created January 9, 2018 09:59
Show Gist options
  • Save jayserdny/c8d37723ec81480049d38f2b1bc71dc1 to your computer and use it in GitHub Desktop.
Save jayserdny/c8d37723ec81480049d38f2b1bc71dc1 to your computer and use it in GitHub Desktop.
Home.ts for steemit tutorial
import { Component } from '@angular/core';
import { NgZone } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Tracker } from 'meteor/tracker';
// Import this module
import { Meteor } from 'meteor/meteor';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
private currentName: string;
private serverResults: string;
private currentUser: string;
autorunComputation: Tracker.Computation;
constructor(public navCtrl: NavController, private zone: NgZone) {
this._initAutorun();
}
_initAutorun(): void {
this.autorunComputation = Tracker.autorun(() => {
this.zone.run(() => {
if (Meteor.user()) {
this.currentUser = Meteor.user().profile.name
}
else {
this.currentUser = "Not Logged In!"
}
})
});
}
private openPage(s: string) {
this.navCtrl.push(s);
}
private openProtected(s: string) {
if (Meteor.user()) {
this.navCtrl.push(s)
}
}
callServer(): void {
// Call Meteor
Meteor.call('cutenessLevel', this.currentName, (error, results) => {
if (!error) {
this.serverResults = results;
}
else {
console.log(error);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment