Skip to main content
edited tags
Link
Rob
  • 27.5k
  • 16
  • 89
  • 103
edited tags
Link
eko
  • 40.8k
  • 11
  • 79
  • 104
Source Link

Angular2 - Add 3rd Party Javascript Library (Summernote)

I'm new to Angular2 and trying to use 3rd party libraries in it. Trying to use summernote Js plugin, used for rich text area. http://summernote.org/getting-started/

This is my my-summernote.component.ts file.

import { ViewChild, ElementRef, AfterViewInit, Component} from '@angular/core';
import '../../assets/plugins/summernote/summernote.min.js';

declare var jQuery: any;

@Component({
    selector: 'my-summernote',
    templateUrl: './my-summernote.template.html'
})
export class SummerNoteComponent implements AfterViewInit {
    constructor(){   
     }
    ngAfterViewInit() {        
        jQuery("#theTextArea").summernote();
    }
}

And here is my-summernote.template.html file

<textarea class="form-control" name="theTextArea" id="theTextArea">                              
    </textarea>

I've included the jquery in index.html file, But i'm getting following error

    Uncaught Error: Cannot find module "codemirror"
        at webpackMissingModule (main.bundle.js:2211)
        at b.function.Array.reduce.Array.reduce.e (main.bundle.js:2211)
        at Object.505 (main.bundle.js:2211)
    Module not found: Error: Cannot resolve module 'codemirror' in C:\Project\Community3.0\CommunityAng\src\assets\plugins\summernote
resolve module codemirror in C:\Project\Community3.0\CommunityAng\src\assets\plugins\summernote
  looking for modules in C:\Project\Community3.0\CommunityAng\src
    C:\Project\Community3.0\CommunityAng\src\codemirror doesn't exist (module as directory)
    resolve 'file' codemirror in C:\Project\Community3.0\CommunityAng\src
      resolve file

Can someone please guide what i'm missing.