Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Typed.js in Angular 4

Tags:

angular

While integrating Typed.js in Angular 4 I get the following error.

ERROR TypeError: __WEBPACK_IMPORTED_MODULE_2_typed_js__.Typed is not a constructor

My component is:

import { Component, OnInit } from '@angular/core';
import { Typed } from 'typed.js';
@Component({
   selector: 'app-home',
   templateUrl: './home.component.html',
   styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

   ngOnInit() {
      let options = {
         strings: ["Books.", "Cinema.", "Paintings.","Music."],
         typeSpeed: 100,
         backSpeed: 100,
         showCursor: true,
         cursorChar: "|",
         loop:true
      }

      let typed = new Typed(".typing-element", options);
   }

}

My Html is:

<div class="container">
   <div class="home-header-title">
      <span class="title">what you like</span>
      <span class="typing-element"></span>
   </div>
</div>
like image 607
Kalyana Kannan Avatar asked Mar 29 '26 22:03

Kalyana Kannan


1 Answers

You should change

import { Typed } from 'typed.js';

to

import * as Typed from 'typed.js';
like image 52
Saurabh Agrawal Avatar answered Apr 03 '26 16:04

Saurabh Agrawal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!