0

I am trying to use the Typed.js library in Angular CLI, but I couldn't manage to make it work. I followed the instructions in How can I use JavaScript code in Angular 7?: copied the jQuery library and typed scrips in assets folder, added a path to the files in angular.json, but I am not sure what to do in the component.ts file:

This is my component.ts code:

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

@Component({
  selector: 'app-typing',
  templateUrl: './typing.component.html',
  styleUrls: ['./typing.component.scss']
})
export class TypingComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    var typed = new Typed('.typed', {
      strings: ["First sentence.", "Second sentence."],
      typeSpeed: 30
    });
  }

  onComplete() {
  }

}

I am pretty sure what I wrote in ngOnInit() is wrong, but how can I make it right?

1
  • Try to import this way : import * as typed from Typed.js'; And after you can use it with typed variable Commented Mar 15, 2019 at 22:10

1 Answer 1

1

You have to import typed.js in order to be able to use it. Declaring it as variable with type of any does not make any sense. Try importing it instead like this: import Typed from 'typed.js';

Sign up to request clarification or add additional context in comments.

2 Comments

the import command doesn t work. It says it cannot find any module there.
Did you install typed.js using npm install typed.js or with other package manager?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.