Skip to content

Instantly share code, notes, and snippets.

@daanl
Created October 30, 2013 20:16
Show Gist options
  • Save daanl/7239487 to your computer and use it in GitHub Desktop.
Save daanl/7239487 to your computer and use it in GitHub Desktop.
Needed plugins wysihtml5 bootstrap-wysihtml5
angular.module('directives', [])
.directive('wysihtml5', ['$timeout', function ($timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function ($scope, $element, attrs, ngModel) {
var element = $($element).wysihtml5({
stylesheets: [],
link: false,
image: false
});
var data = element.data('wysihtml5');
var editor = data.editor;
// ensure template is renderd
$timeout(function() {
editor.on('change', function () {
var newValue = element.val();
$scope.$apply(function() {
ngModel.$setViewValue(newValue);
});
});
}, 500);
}
};
}]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment