rnaffer
6/2/2016 - 7:41 PM

Directiva ng-model para wysiwyg

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();
              }
      });
   }
 };
});