Reputation: 53
I am creating a component to use summernote in my angular app but I get "$(...).summernote is not a function" error. properly after loading the page summernote has not get loaded. but I dont know really what to do to solve this problem.
the code in component:
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"
]
},
Upvotes: 1
Views: 1234
Reputation: 48968
Load the summernote library after the jQuery library:
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",
]
Upvotes: 2