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

Commit 0d124e1

Browse files
committedJul 8, 2013
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 96298f9 commit 0d124e1

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
@@ -887,7 +887,13 @@ var VALID_CLASS = 'ng-valid',
887887
888888
// Write data to the model
889889
function read() {
890-
ngModel.$setViewValue(element.html());
890+
var html = element.html();
891+
// When we clear the content editable the browser leaves a <br> behind
892+
// If strip-br attribute is provided then we strip this out
893+
if( attrs.stripBr && html == '<br>' ) {
894+
html = '';
895+
}
896+
ngModel.$setViewValue(html);
891897
}
892898
}
893899
};
@@ -897,6 +903,7 @@ var VALID_CLASS = 'ng-valid',
897903
<form name="myForm">
898904
<div contenteditable
899905
name="myWidget" ng-model="userContent"
906+
strip-br="true"
900907
required>Change me!</div>
901908
<span ng-show="myForm.myWidget.$error.required">Required!</span>
902909
<hr>

0 commit comments

Comments
 (0)
This repository has been archived.