Created
October 30, 2013 20:16
-
-
Save daanl/7239487 to your computer and use it in GitHub Desktop.
Needed plugins
wysihtml5
bootstrap-wysihtml5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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