Search code examples
angularangular6bulma

Calling imported javascript from Angular 6


I'm trying to use the bulma-calendar extension in my Angular 6 project and so in angular.json I add the bulma-calendar.min.js file to the scripts section.

What I can't figure out now is how to actually call that code. I know it makes an export of bulmaCalendar but I'm not familiar enough with Angular to know how to reference that code.


Solution

  • First you import it:

    import * as BulmaCalendar from '.your-path'

    Because Bulma calendar exports a constructor function:

    export default class bulmaCalendar extends EventEmitter {
      constructor(selector, options = {}) {
    

    You can instainiate it like:

    let bulmaInstance = new BulmaCalendar('.some-selector', { option1: someval } )