Skip to content

Instantly share code, notes, and snippets.

@rnaffer
Created June 2, 2016 19:41
Show Gist options
  • Select an option

  • Save rnaffer/f14d70a23b3fd9974b67e109e4fbdd91 to your computer and use it in GitHub Desktop.

Select an option

Save rnaffer/f14d70a23b3fd9974b67e109e4fbdd91 to your computer and use it in GitHub Desktop.
Directiva ng-model para wysiwyg
app.directive('textEditor', function () {
return {
require: 'ngModel',
link: function(scope, element, attributes, controller) {
scope.$watch(attributes.ngModel, function(value) {
$(element).html(value);
});
element.bind('keyup mouseup', function(){
controller.$setViewValue(element.html());
if (!scope.$$phase) {
scope.$apply();
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment