How to create a component in Angular 2 that imports the QuillJS module?

I am new to Angular 2 and TypeScript. I use AngularCLI and NPM to create my Angular project. I used NPM to install the quill node module in my project. Now I am trying to create a component in which I can configure my message editor through my API.

I am trying to use:

import * as Quill from 'quill'; 

This returns the error 'can not find quill module'.

I have already added

"": "0.0.26",
"quill": "^1.0.4",

to package.json as dependencies.

+4
source share
1 answer

I tried to reproduce your problem in the Angular CLI home project generated by the team ng newand it worked fine. Here is the code:

import { Component } from '@angular/core';
import * as Quill from 'quill';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app works!';

  ngOnInit() {
    console.log(Quill);
  }
}
Run codeHide result
, :

node_modules quill, , , node_modules npm i

+3

Source: https://habr.com/ru/post/1681628/


All Articles