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

Commit

Permalink
docs(ngModelController): provide a more intuitive example
Browse files Browse the repository at this point in the history
The example directive, using contenteditable was not showing required
even if you cleared the content from it.

Closes #3156
  • Loading branch information
petebacondarwin committed Jul 8, 2013
1 parent 96298f9 commit 0d124e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
Expand All @@ -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>
Expand Down

0 comments on commit 0d124e1

Please sign in to comment.