angular/angular.js — pull request #5221 by g00fy- (2013-12-01 15:17:30+00:00)
Title: feat(ngModelController): expose $setModelValue

### General usecase:

- allow other directives requiring `ngModel` to easily assign model value
- `$setViewValue` works only with basic "flat" values like strings or numbers (eg not objects).

currently similar thing can be achieved by using

```javascript
$parse(attr.ngModel).assign(scope.$parent,modelValue)
```

but this approach gets more complicated with multiple directives and isolate scopes.

### Specific usecase:

AutoComplete input directive returning objects instead of values.

```html

```

parser:

```javascript
function(value){ return {name:value} )
```

formatter:
```javascript
function(value){
return angular.isObject(value) ? value.name : value
}
````

the user list dropdown template:

```html
{{user.name}}

```

and the `select` function would be:

```javascript
function(user){
ngModel.$setModelValue(user)
}
```