Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 62d552f

Browse files
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
1 parent bcaa421 commit 62d552f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ng/directive/input.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,13 @@ var VALID_CLASS = 'ng-valid',
866866
867867
// Write data to the model
868868
function read() {
869-
ngModel.$setViewValue(element.html());
869+
var html = element.html();
870+
// When we clear the content editable the browser leaves a <br> behind
871+
// If strip-br attribute is provided then we strip this out
872+
if( attrs.stripBr && html == '<br>' ) {
873+
html = '';
874+
}
875+
ngModel.$setViewValue(html);
870876
}
871877
}
872878
};
@@ -876,6 +882,7 @@ var VALID_CLASS = 'ng-valid',
876882
<form name="myForm">
877883
<div contenteditable
878884
name="myWidget" ng-model="userContent"
885+
strip-br="true"
879886
required>Change me!</div>
880887
<span ng-show="myForm.myWidget.$error.required">Required!</span>
881888
<hr>

0 commit comments

Comments
 (0)