arsinawaz
arsinawaz

Reputation: 480

Include a library without npm or bower

I am using angularjs 1.4 as my front-end framework, i want to include this library https://github.com/taylorhakes/promise-polyfill

but i do not have bower or npm setup in my front-end application. I am new to this field.

I have tried to include the library like below:

<script src="js/promise.min.js"></script>

and then placed code below in the index.html after i have included the library

import Promise from 'promise-polyfill'; 
if (!window.Promise) {
  window.Promise = Promise;
}

but it doesn't work.

Upvotes: 1

Views: 228

Answers (1)

lin
lin

Reputation: 18392

You currently mix TypeScript with JavaScript. You could do it with JavaScript like:

define(["require", "exports", "promise-polyfill"], function (
    require, 
    exports, 
    promise_polyfill
    ){
        "use strict";
        if (!window.Promise) {
            window.Promise = promise_polyfill.default;
        }
    }
);

Upvotes: 1

Related Questions