Created
June 2, 2016 19:41
-
-
Save rnaffer/f14d70a23b3fd9974b67e109e4fbdd91 to your computer and use it in GitHub Desktop.
Directiva ng-model para wysiwyg
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
| 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