diff options
| author | Pete Bacon Darwin | 2013-07-08 14:52:31 +0100 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-07-08 14:53:15 +0100 | 
| commit | 62d552ffe229aabfc9bc50c1fac00d3f1835c891 (patch) | |
| tree | 7376ae35bfeb8d822eeb1ee71dd0f711749ec936 /src/ng | |
| parent | bcaa4217bc4f2970560ae660b589042ae2c4d976 (diff) | |
| download | angular.js-62d552ffe229aabfc9bc50c1fac00d3f1835c891.tar.bz2 | |
docs(ngModelController): provide a more intuitive example
The example directive, using contenteditable was not showing required
even if you cleared the content from it.
Closes #3156
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/directive/input.js | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 3630512a..c122caf0 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -866,7 +866,13 @@ var VALID_CLASS = 'ng-valid',                // Write data to the model                function read() { -                ngModel.$setViewValue(element.html()); +                var html = element.html(); +                // When we clear the content editable the browser leaves a <br> behind +                // If strip-br attribute is provided then we strip this out +                if( attrs.stripBr && html == '<br>' ) { +                  html = ''; +                } +                ngModel.$setViewValue(html);                }              }            }; @@ -876,6 +882,7 @@ var VALID_CLASS = 'ng-valid',        <form name="myForm">         <div contenteditable              name="myWidget" ng-model="userContent" +            strip-br="true"              required>Change me!</div>          <span ng-show="myForm.myWidget.$error.required">Required!</span>         <hr>  | 
