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

别等时光非礼了梦想. 提交于 2020-01-03 15:34:19

问题


I am fairly new to Angular 2 and TypeScript. I am using AngularCLI and NPM to create my Angular Project. I have used NPM to install the quill node module into my project. I am now trying to create a component in which I can customize my quill editor through their API.

I am trying to use:

import * as Quill from 'quill'; 

This is returning a 'cannot find quill module' error.

I have already added

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

to package.json as dependencies.


回答1:


I tried to reproduce your issue in a pet Angular CLI project generated with the ng new command, and 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);
  }
}
And here's the output I get: Image Link

Go to you project's node_modules folder and look for a folder named quill, anyway, even if it is there, delete the node_modules folder and run npm i command again



来源:https://stackoverflow.com/questions/45149376/how-do-i-create-a-component-in-angular-2-that-imports-the-quilljs-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!