Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use summernote with angularjs

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

like image 981
Rico Berger Avatar asked Oct 31 '14 18:10

Rico Berger


People also ask

How do you implement Summernote?

There are 2 ways to use the Summernote Editor on our web page: Using the downloaded precompiled and minified versions of CSS and JavaScript files from their official site. Using the available CDN links for summernote CSS & js, jQuery, and Bootstrap.

What is Summernote in angular?

angular-summernote is just a directive to bind summmernote's all features. You can use summernote with angular way. Since v0. 7. x, the version of angular-summernote follows the version of summernote.

What is Summernote?

Summernote is a JavaScript library that helps you create WYSIWYG editors online.

How do I add a placeholder in Summernote?

You can define a placeholder with the placeholder option. $('#summernote'). summernote({ placeholder: 'write here...' }); Summernote can also be set to inherit the placeholder from the placeholder attribute on the dom element.


1 Answers

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

like image 74
Rico Berger Avatar answered Sep 18 '22 06:09

Rico Berger