import { EventEmitter, Component, Output, OnInit } from "@angular/core"; import { Platform, NavParams, ViewController } from 'ionic-angular'; import { Reference } from '../../libs/Reference'; import { StrongsResult, StrongsService } from '../../services/strongs-service'; @Component({ selector: "strongs-modal", templateUrl: "strongs-modal.html", providers: [StrongsService] }) export class StrongsModal implements OnInit { sn: number; dict: string; item: StrongsResult; @Output() onItemClicked = new EventEmitter(); constructor(private strongsService: StrongsService, public platform: Platform, public params: NavParams, public viewCtrl: ViewController ) { this.sn = this.params.get('sn') as number; this.dict = this.params.get('dict') as string; this.onItemClicked.subscribe(item => this.params.get('onItemClicked').getItems(item) ) } ngOnInit(): void { this.strongsService.getResultAsPromise(this.sn, this.dict).then(data => this.item = data); } dismiss() { this.viewCtrl.dismiss(); } openItem(p: string) { this.onItemClicked.emit(p); this.dismiss(); } makePassage(p: string) { return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2]; } openPassage(p: string) { let ref = this.makePassage(p); this.onItemClicked.emit(ref); } }