How to use summernote with angularjs

Rico Berger picture Rico Berger · Oct 31, 2014 · Viewed 12.6k times · Source

I would use summernote with AngularJS. I have found https://github.com/outsideris/angular-summernote, but this doesn't work for me. The only thing I get is an Error

Error: undefined is not a function (evaluating 'element.summernote(summernoteConfig)')

I have included all required files like jquery, bootstrap, summernote, etc.

My second idea was to use summer note without the angular-summernote directive. But also that shouldn't work perfectly.

If I try

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

summernote doesn't work, but If I try sth. like

$.getScript('//cdnjs.cloudflare.com/ajax/libs/summernote/0.5.1/summernote.min.js',function(){
  $('#summernote').summernote();
});

it works, but I would use my local copy of summernote so the second one isn't that what I need

Hope you understood my problem and thanks for any help Rico

Answer

Rico Berger picture Rico Berger · Nov 1, 2014

Ok guys, I've found the problem, for everyone with the same problem it's a very stupid mistake ;)

The problem was the I include the main angular.min.js file before jQuery an Bootstrap. Now I include jQuery first, then Bootstrap and then AngularJS and it works perfect.

<link rel="stylesheet" type="text/css" href="bootstrap.css" />
<link rel="stylesheet" type="text/css" href="summernote.css" />
<script src="jquery-2.1.1.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="summernote.min.js"></script>
<script src="angular.min.js"></script>
<script src="angular-summernote.min.js"></script>

In this order it works perfect for me.

A short tip, if you have also a problem with the button size, only thing to do is include <!DOCTYPE html> in you're main html file.

Rico