title: Angular2/4. Can I bind a function to ngModel?
body: <p>I am using ngbDatePicker from the ng-bootstrap. I am trying to set a default date which is returned from an API. This doesn't seem to work as either i get errors or the browser freezes. The code snippet looks like this</p>
  
  <p><code>&lt;input class="form-control" placeholder="dd-mm-yyyy" name="from" [ngModel]="formatDate(filter.nodes[0])" (ngModelChange)="filter.nodes[0] = updateDate($event)" ngbDatepicker #d1="ngbDatepicker"&gt;</code></p>
  
  <p>filter.nodes[0] is the date value that is returned from the API as a string. I need to format this into a JS Object for it to bind to the input. </p>