Angular2 Interfacing with External JS E.g. PouchDB

Introduction

This blog demonstrates how to interface Angular2 TypeScript with JavaScript.

PouchDB is used as an example JavaScript library.

How to setup a PouchDB in JavaScript

How to setup PouchDB in general is simple as explained here: https://pouchdb.com/

Add PouchDB to index.html

<script src="https://cdn.jsdelivr.net/pouchdb/6.0.5/pouchdb.min.js"></script>

This one line of code sets up a database called “dbName”;

var db = new PouchDB('dbname');

Simple as that, now it’s possible to call db.put(), db.post(''') db.addDocs()  etc.

Diving Straight into TypeScript and PouchDB

Add PouchDB to your application

Continue reading “Angular2 Interfacing with External JS E.g. PouchDB”