0

I'm using flickity with the cdn, but when it loads the page does not work. I already put the script in index.html, but it does not work

component.ts

declare var jquery:any;
declare var $ :any;

export class ProfileComponent implements OnInit {
  constructor() {
      $('.carousel-category').flickity({
        freeScroll: true,
        contain: true,
        prevNextButtons: false,
        pageDots: false
      })
  }
}
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • When your component is constructed, its template has not been rendered in the DOM yet. You most probably need to put that code in the ngAfterViewInit hook. This hook is called when the component template has been rendered. – JB Nizet Apr 01 '18 at 08:39
  • it did not work @JBNizet – Carlos Uriel Santiago Apr 01 '18 at 08:44
  • Some unknown code cause some unknown problem. I can't work with that. Edit your question, post all the relevant code. Tell us precisely what you expect to happen and what happens instead. – JB Nizet Apr 01 '18 at 08:48
  • 1
    It works very well here (and I had never heard of flickity before): https://stackblitz.com/edit/angular-4qcjcv?file=app%2Fapp.component.ts – JB Nizet Apr 01 '18 at 08:53
  • @JBNizet, try to import Flickity as a dependency of the project and import its files in angular-cli.json. I made this changes in this stackblitz and it stopped to work. I am looking for a fix in this specific scenario. – mxmlc Aug 13 '18 at 17:26

0 Answers0