Ulises Giacoman Ulises Giacoman - 1 year ago 234
Javascript Question

Angular2 RC5 Importing 3rd Party JS Library: Showdown

I'm having trouble importing Showdown as a vendor. When I compile, I get

showdown is not defined
in the browser console. Since it is a vendor package, I don't think I can import it inside of
. Do I need to declare a custom typing for it? The package is all in
. I am running on Angular2 RC5. Thanks!


import 'showdown/dist/showdown';

declare var showdown: any;

private extractData(res: Response) {
let body = res.json();
var converter = new showdown.Converter(),
originalBody = window.atob(body.content),
body.title = converter.makeHtml(title);


import 'showdown/dist/showdown';

Answer Source

Solution was to employ typings mentioned by Yakov Fain

import {Converter} from "showdown/dist/showdown";

const converter = new Converter();
var body.title = converter.makeHtml(title);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download