在Angular 4应用程序中使用waypoints.js

时间:2018-01-08 05:41:39

标签: javascript angular typescript

嘿我试图在我的角度应用程序中使用Waypoints.js ..我似乎无法让它工作

角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');
      }
    });

  }

我收到了错误.. enter image description here

任何帮助将不胜感激

谢谢!

修改

我已经安装了Waypoint类型并导入了它import * as Waypoint from 'waypoints';

收到错误[ts] file pathtofolder/@types/waypoints/index.d.ts is not a module

2 个答案:

答案 0 :(得分:0)

安装Waypoints types以安装航点类型。

import * as Waypoint from 'waypoints'.

我希望它可能有所帮助。

答案 1 :(得分:0)

在app.component.ts中替换

declare var Waypoint: any;

declare const Waypoint: any;

可以解决问题。

P.S:目前,我正在使用Angular 7,该解决方案对我有效。