1

I'm trying to add a third party library to angular2, namely the Flickity slider.

Tried to install typings. When importing them I get en error that @typings/flickity is not a module.

Second attempt to add it in angular-cli.json. Added in apps[0].scripts as described in the docs. In the component i've used it like this:

this.slider = new Flickity('.news-wrapper', { cellAlign: 'left', contain: true, prevNextButtons: false, pageDots: true });

When compiling I get an error Cannot find name 'Flickity'., but when running the site it works like a charm.

The problem is I can't build the app because of that error.

How should it be added then?

1
  • HI, I am also trying to use flickity with angular2. can you please share your success story and how u did? i am using angular cli Commented Dec 13, 2016 at 6:41

2 Answers 2

3

follow below steps to use flickity in angular-cli based project

  1. npm install flickity --save
  2. declare module 'flickity'; in typings.d.ts
  3. import * as Flickity from "flickity"; in app.component.ts (needs to import wherever required)

use it like as you mentioned

this.slider = new Flickity('.news-wrapper', { cellAlign: 'left', contain: true, prevNextButtons: false, pageDots: true });
Sign up to request clarification or add additional context in comments.

3 Comments

hi, i am new to angular 2, how can we declare module 'flickity'; in typings.d.ts??
@shajeeck add this line to typings.d.ts declare module 'flickity';
This solved my issue. @types/flickity was not working
0

I am not sure if this will work but you can try this in the file that needs flickity.

let Flickity = require('flickity');

Just make sure you installed let Flickity using NPM

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.