diff options
| author | Misko Hevery | 2011-11-22 21:28:39 -0800 |
|---|---|---|
| committer | Misko Hevery | 2012-01-25 11:50:37 -0800 |
| commit | 9ee2cdff44e7d496774b340de816344126c457b3 (patch) | |
| tree | 476ffcb4425e7160865029d6b57d41b766750285 /docs/content | |
| parent | 8af4fde18246ac1587b471a549e70d5d858bf0ee (diff) | |
| download | angular.js-9ee2cdff44e7d496774b340de816344126c457b3.tar.bz2 | |
refactor(directives): connect new compiler
- turn everything into a directive
Diffstat (limited to 'docs/content')
| -rw-r--r-- | docs/content/api/angular.inputType.ngdoc | 2 | ||||
| -rw-r--r-- | docs/content/guide/dev_guide.expressions.ngdoc | 16 | ||||
| -rw-r--r-- | docs/content/guide/dev_guide.forms.ngdoc | 49 |
3 files changed, 36 insertions, 31 deletions
diff --git a/docs/content/api/angular.inputType.ngdoc b/docs/content/api/angular.inputType.ngdoc index bfd5fe6f..9cbf9eb2 100644 --- a/docs/content/api/angular.inputType.ngdoc +++ b/docs/content/api/angular.inputType.ngdoc @@ -84,7 +84,7 @@ All `inputType` widgets support: it('should invalidate on wrong input', function() { expect(element('form[name=myForm]').prop('className')).toMatch('ng-valid'); input('data').enter('{}'); - expect(binding('data')).toEqual('data={\n }'); + expect(binding('data')).toEqual('{}'); input('data').enter('{'); expect(element('form[name=myForm]').prop('className')).toMatch('ng-invalid'); }); diff --git a/docs/content/guide/dev_guide.expressions.ngdoc b/docs/content/guide/dev_guide.expressions.ngdoc index b7ecc521..61592897 100644 --- a/docs/content/guide/dev_guide.expressions.ngdoc +++ b/docs/content/guide/dev_guide.expressions.ngdoc @@ -185,16 +185,20 @@ Extensions: You can further extend the expression vocabulary by adding new metho {name:'Julie', phone:'555-8765'}]"></div> Search: <input ng:model="searchText"/> <table class="example3"> - <tr><th>Name</th><th>Phone</th><tr> - <tr ng:repeat="friend in friends | filter:searchText"> - <td>{{friend.name}}</td> - <td>{{friend.phone}}</td> - </tr> + <thead> + <tr><th>Name</th><th>Phone</th><tr> + </thead> + <tbody> + <tr ng:repeat="friend in friends | filter:searchText"> + <td>{{friend.name}}</td> + <td>{{friend.phone}}</td> + </tr> + </tbody> </table> </doc:source> <doc:scenario> it('should filter the list', function() { - var tr = using('table.example3').repeater('tr.ng-attr-widget'); + var tr = using('table.example3 tbody').repeater('tr'); expect(tr.count()).toBe(5); input('searchText').enter('a'); expect(tr.count()).toBe(2); diff --git a/docs/content/guide/dev_guide.forms.ngdoc b/docs/content/guide/dev_guide.forms.ngdoc index 35f42036..c33596e6 100644 --- a/docs/content/guide/dev_guide.forms.ngdoc +++ b/docs/content/guide/dev_guide.forms.ngdoc @@ -277,20 +277,20 @@ The following example demonstrates: This example shows how to implement a custom HTML editor widget in Angular. - <doc:example> + <doc:example module="formModule"> <doc:source> <script> function EditorCntl($scope) { $scope.htmlContent = '<b>Hello</b> <i>World</i>!'; } - HTMLEditorWidget.$inject = ['$element', '$scope', 'htmlFilter']; - function HTMLEditorWidget(element, scope, htmlFilter) { + HTMLEditorWidget.$inject = ['$scope', '$element', '$sanitize']; + function HTMLEditorWidget(scope, element, $sanitize) { scope.$parseModel = function() { // need to protect for script injection try { - this.$viewValue = htmlFilter( - this.$modelValue || '').get(); + this.$viewValue = $sanitize( + this.$modelValue || ''); if (this.$error.HTML) { // we were invalid, but now we are OK. this.$emit('$valid', 'HTML'); @@ -312,24 +312,25 @@ This example shows how to implement a custom HTML editor widget in Angular. }); } - angular.directive('ng:html-editor-model', function() { - return ['$formFactory', '$element', function ($formFactory, element) { - var exp = element.attr('ng:html-editor-model'), - 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(); - }); - }]; - }); + 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> @@ -337,7 +338,7 @@ This example shows how to implement a custom HTML editor widget in Angular. HTML: <br/> <textarea ng:model="htmlContent" cols="80"></textarea> <hr/> - <pre>editorForm = {{editorForm}}</pre> + <pre>editorForm = {{editorForm|json}}</pre> </form> </doc:source> <doc:scenario> |
