I am trying to make an app which can open to read epub files. So I have tried to import this Epub.js javascript library according to this article. I am done with the arrangements in the article. So with code below I am trying to use epub.js in my Ionic 2 app in windows 10 and chrome browser. But I am getting this error below. Why am I getting this error?
ecatalog.ts
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {epubjs} from "epubjs";
@Component({
selector: 'page-ecatalog',
templateUrl: 'ecatalog.html'
})
export class EcatalogPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
var Book = epubjs.ePub("../www/books/k1ecatalog.epub");
Book.renderTo("area");
}
}
ecatalog.html
<ion-content>
<div onclick="Book.prevPage();">‹</div>
<div id="area"></div>
<div onclick="Book.nextPage();">›</div>
</ion-content>
Error:
Runtime Error
Error in ./MyApp class MyApp - caused by: Cannot read property 'ePub' of undefined
Stack
TypeError: Cannot read property 'ePub' of undefined
at new EcatalogPage (http ://192.16 8.33.11:8100/build/main.js:58587:66)
at new Wrapper_EcatalogPage (/AppModule/EcatalogPage/wrapper.ngfactory.js:7:18)
at CompiledTemplate.proxyViewClass.View_EcatalogPage_Host0.createInternal (/AppModule/EcatalogPage/host.ngfactory.js:15:26)
at CompiledTemplate.proxyViewClass.AppView.createHostView (http: //192 .168.33.11:8100/build/main.js:99490:21)
at CompiledTemplate.proxyViewClass.DebugAppView.createHostView...