1

Hey Im trying to use Waypoints.js in my angular application.. I cant seem to get it to work

angular-cli.js

"scripts": [
    "../node_modules/waypoints/lib/noframework.waypoints.min.js"
  ]

app.component.ts

import { Component,  OnInit } from '@angular/core';
    declare var Waypoint: any;

export class OurTechnologyComponent implements OnInit {

  constructor() {}

  ngOnInit() {

    //waypoints
    const grinner = new Waypoint({
      element: document.querySelector('.tech-section'),
      handler: function () {
        alert('hello');
      }
    });

  }

I am getting an error.. enter image description here

Any help would be appreciated

Thanks!

edit

Ive installed Waypoints Types and have imported it import * as Waypoint from 'waypoints';

getting error [ts] file pathtofolder/@types/waypoints/index.d.ts is not a module

Smokey Dawson
  • 8,827
  • 19
  • 77
  • 152

2 Answers2

1

In app.component.ts replace

declare var Waypoint: any;

with

declare const Waypoint: any;

will do the trick.

P.S: I am using Angular 7 at the moment and this solution works for me.

Junaid
  • 2,572
  • 6
  • 41
  • 77
0

Install Waypoints types for installing type for waypoint.

import * as Waypoint from 'waypoints'.

I hope it might helps.

Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112
Ajay
  • 4,773
  • 3
  • 23
  • 36
  • 1
    Im getting this error `[ts] file pathtofolder/@types/waypoints/index.d.ts is not a module` – Smokey Dawson Jan 08 '18 at 05:52
  • @A61NN5 waypoints interface library needs an updation. For now you can declare the export for each class inside index.d.ts. Use export package_name = package_name. this should work. – Ajay Jan 08 '18 at 06:02
  • This is follow up question, tried to implement your solution but didn't. Please have a look at https://stackoverflow.com/questions/53854977/angular-waypoints-typescript-error-module-not-found – Junaid Apr 09 '19 at 19:08