diff options
| author | Misko Hevery | 2011-11-29 12:11:32 -0800 |
|---|---|---|
| committer | Misko Hevery | 2012-01-25 11:46:36 -0800 |
| commit | 8af4fde18246ac1587b471a549e70d5d858bf0ee (patch) | |
| tree | 925e223c9221c8e3b40ff3fb5cade11b819782d5 /src/service/formFactory.js | |
| parent | 5001c1a1217772d2bffe108bafd475b24badf559 (diff) | |
| download | angular.js-8af4fde18246ac1587b471a549e70d5d858bf0ee.tar.bz2 | |
add($compile): add compiler v2.0 - not connected
Diffstat (limited to 'src/service/formFactory.js')
| -rw-r--r-- | src/service/formFactory.js | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/src/service/formFactory.js b/src/service/formFactory.js index 69c6d717..727a243c 100644 --- a/src/service/formFactory.js +++ b/src/service/formFactory.js @@ -56,41 +56,43 @@ }); } - angular.directive('ng:contenteditable', function() { - return ['$formFactory', '$element', function ($formFactory, element) { - var exp = element.attr('ng:contenteditable'), - form = $formFactory.forElement(element), - widget; - element.attr('contentEditable', true); - widget = form.$createWidget({ - scope: this, - model: exp, - controller: HTMLEditorWidget, - controllerArgs: {$element: element}}); - // if the element is destroyed, then we need to notify the form. - element.bind('$destroy', function() { - widget.$destroy(); - }); - }]; - }); - </script> - <form name='editorForm' ng:controller="EditorCntl"> - <div ng:contenteditable="html"></div> - <hr/> - HTML: <br/> - <textarea ng:model="html" cols=80></textarea> - <hr/> - <pre>editorForm = {{editorForm}}</pre> - </form> - </doc:source> - <doc:scenario> - it('should enter invalid HTML', function() { - expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-valid/); - input('html').enter('<'); - expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-invalid/); - }); - </doc:scenario> - </doc:example> + angular.module('formModule', [], function($compileProvider){ + $compileProvider.directive('ngHtmlEditorModel', function ($formFactory) { + return function(scope, element, attr) { + var form = $formFactory.forElement(element), + widget; + element.attr('contentEditable', true); + widget = form.$createWidget({ + scope: scope, + model: attr.ngHtmlEditorModel, + controller: HTMLEditorWidget, + controllerArgs: {$element: element}}); + // if the element is destroyed, then we need to + // notify the form. + element.bind('$destroy', function() { + widget.$destroy(); + }); + }; + }); + }); + </script> + <form name='editorForm' ng:controller="EditorCntl"> + <div ng:html-editor-model="htmlContent"></div> + <hr/> + HTML: <br/> + <textarea ng:model="htmlContent" cols="80"></textarea> + <hr/> + <pre>editorForm = {{editorForm|json}}</pre> + </form> + </doc:source> + <doc:scenario> + it('should enter invalid HTML', function() { + expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-valid/); + input('htmlContent').enter('<'); + expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-invalid/); + }); + </doc:scenario> + </doc:example> */ /** |
