angular-ui/ui-codemirror — pull request #20 by bfcamara (2013-10-02 13:27:40+00:00)
Title: making sure is passing a string to the codeMirror 

codeMirror expectes a string.

Adding a formatter is not enough to make sure that the editor receives a
sting, since the ngModel can have multiple formatters registered.

For example, if we have a ui-codemirror textarea combined with required

```HTML

```
the ngModel will have two formatters: the ui-codemirror and the
required.

When $scope.vm.myfield is undefined, the required formatter returns
undefined, and this will be the last formatter to run

Here is the exception we will get from codemirror

TypeError: Cannot call method 'split' of undefined
at window.CodeMirror.splitLines
(http://localhost:1995/Scripts/codemirror/codemirror.js:5570:38)
at window.CodeMirror.createObj.setValue
(http://localhost:1995/Scripts/codemirror/codemirror.js:4773:31)
at null.setValue
(http://localhost:1995/Scripts/codemirror/codemirror.js:4972:40)
at link.ngModel.$render
(http://localhost:1995/Scripts/ui-codemirror.js:81:26)
at Object.ngModelWatch
(http://localhost:1995/Scripts/angular.js:14504:14)
at Object.watchExpression (:754:29)
at Scope.$digest (http://localhost:1995/Scripts/angular.js:9897:47)
at Scope.$delegate.__proto__.$digest (:844:31)
at Scope.$apply (http://localhost:1995/Scripts/angular.js:10137:24)
at Scope.$delegate.__proto__.$apply (:855:30)

Here is the formatter of required directive (from angular sources)

```javascript
var validator = function(value) {
if (attr.required &&
(isEmpty(value) || value === false)) {

ctrl.$setValidity('required', false);
return;
} else
{
ctrl.$setValidity('required', true);
return
value;
}
};

ctrl.$formatters.push(validator);
```

As we can se the formatter returns undefined if the value isEmpty