mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-22 21:25:47 +00:00
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
This commit is contained in:
parent
96298f9179
commit
0d124e190b
1 changed files with 8 additions and 1 deletions
|
|
@ -887,7 +887,13 @@ var VALID_CLASS = 'ng-valid',
|
||||||
|
|
||||||
// Write data to the model
|
// Write data to the model
|
||||||
function read() {
|
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">
|
<form name="myForm">
|
||||||
<div contenteditable
|
<div contenteditable
|
||||||
name="myWidget" ng-model="userContent"
|
name="myWidget" ng-model="userContent"
|
||||||
|
strip-br="true"
|
||||||
required>Change me!</div>
|
required>Change me!</div>
|
||||||
<span ng-show="myForm.myWidget.$error.required">Required!</span>
|
<span ng-show="myForm.myWidget.$error.required">Required!</span>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue