Skip to content

Commit

Permalink
Step 7.7: Define component's method to open options
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and dotansimha committed Nov 27, 2016
1 parent 76f2970 commit a02598d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/imports/pages/chat/messages-page.component.ts
@@ -1,12 +1,13 @@
import {Component, OnInit, OnDestroy} from "@angular/core";
import {NavParams} from "ionic-angular";
import {NavParams, PopoverController} from "ionic-angular";
import {Meteor} from 'meteor/meteor';
import {Chat} from "../../../../both/models/chat.model";
import {Messages} from "../../../../both/collections/messages.collection";
import {Observable, Subscription} from "rxjs";
import {Message} from "../../../../both/models/message.model";
import template from "./messages-page.component.html";
import style from "./messages-page.component.scss";
import {MessagesOptionsComponent} from './messages-options.component';
import {MeteorObservable} from "meteor-rxjs";

@Component({
Expand All @@ -25,7 +26,10 @@ export class MessagesPage implements OnInit, OnDestroy {
private message = "";
private autoScroller: Subscription;

constructor(navParams: NavParams) {
constructor(
navParams: NavParams,
private popoverCtrl: PopoverController
) {
this.selectedChat = <Chat>navParams.get('chat');
this.title = this.selectedChat.title;
this.picture = this.selectedChat.picture;
Expand Down Expand Up @@ -70,6 +74,16 @@ export class MessagesPage implements OnInit, OnDestroy {
return this.messagesList.querySelector('.scroll-content');
}

showOptions(): void {
const popover = this.popoverCtrl.create(MessagesOptionsComponent, {
chat: this.selectedChat
}, {
cssClass: 'options-popover'
});

popover.present();
}

ngOnDestroy() {
if (this.autoScroller) {
this.autoScroller.unsubscribe();
Expand Down

0 comments on commit a02598d

Please sign in to comment.