Programatically update input value from directive in Angular 2

Viewed 26392

I have this template in a component:

...
<div class="myCustomDirective">
    <input name="value" type="text" [(ngModel)]="value" />
</div>
...

I want to update the value from myCustomDirective. Updating the input element directly like this:

this.elementRef.nativeElement.querySelector('input').value = 'bla';

... doesn't update the model in the component.

Using Angular 4.2.6.

3 Answers
Related