Ошибка "$ (...). summernote не является функцией" в Angular 8 - PullRequest
0 голосов
/ 02 ноября 2019

Я создаю компонент для использования summernote в моем угловом приложении, но получаю ошибку «$ (...). Summernote - это не функция». правильно после загрузки страницы summernote не загружается. но я действительно не знаю, что делать, чтобы решить эту проблему.

код в компоненте:

import { Component,OnInit,ElementRef } from '@angular/core';
declare var $: any;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {  
constructor( private elementRef:ElementRef){
}
ngOnInit(){
}

 ngAfterViewInit(){
  console.log("after view init")

  $(document).ready(function(){
    $('#summernote').summernote();
  })
 }
}

angular.json:

    "assets": [
        "src/assets",
        "src/manifest.json",
        "src/icons"
    ],
    "styles": [
        "src/styles.css",
        "node_modules/bootstrap/dist/css/bootstrap.min.css",
        "node_modules/summernote/dist/summernote.css"
    ],
    "scripts": [
        "node_modules/summernote/dist/summernote.js",
        "node_modules/jquery/dist/jquery.js"
    ]
},

1 Ответ

0 голосов
/ 02 ноября 2019

Загрузить библиотеку summernote после библиотеки jQuery:

ERRONEOUS

"scripts": [
    "node_modules/summernote/dist/summernote.js",
    "node_modules/jquery/dist/jquery.js"
]

Лучше

"scripts": [
    "node_modules/jquery/dist/jquery.js"
    "node_modules/summernote/dist/summernote.js",
]
...