aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPete Bacon Darwin2013-07-08 14:52:31 +0100
committerPete Bacon Darwin2013-07-08 14:52:31 +0100
commit0d124e190b24e737405b467d4fc11f10047b3d9c (patch)
tree6d75e39cc9f88471b8f074797af0587415ad2225 /src
parent96298f9179ebe366e83ad0abd02888c87438634d (diff)
downloadangular.js-0d124e190b24e737405b467d4fc11f10047b3d9c.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')
-rw-r--r--src/ng/directive/input.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index a5fc56c8..5fb0fb14 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -887,7 +887,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);
}
}
};
@@ -897,6 +903,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>