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>
You should change
import { Typed } from 'typed.js';
to
import * as Typed from 'typed.js';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With