Question: I am using [this](https://valor-software.com/ngx-bootstrap/#/typeahead) link for implementing a Typeahead. Now I am using TypeaheadOptionField to display a name on typeahead but it also binds the name string in the model. I want to bind the Object instead of the string.

My HTML Code:

```
<input formControlName="item"  class="form-control" [typeahead]="allItemsArray" [typeaheadItemTemplate]="customItemTemplate"
          [typeaheadOptionsLimit]="7" [typeaheadMinLength]="0" [typeaheadOptionField]="name" (typeaheadOnSelect)="onSelectItem($event)">

```

allItemsArray:

```
[
    {
        name: 'a',
        code: '12'
    },
    {
        name: 'b',
        code: '13'
    }
]

Value bound to form control: 'a'
Required value: {'name': 'a', 'code': '12'}

```

One thing I tried is implementing an event which sets the model value as object but it didn't work.

Answer: 
Please read the error message. It's very clear. In `setValue` you are passing a `String` (via String Interpolation) rather than expected `Int` or `NSNumber`

```
object.setValue(jobId, forKey: "jobId")

```

or 

```
object.setValue(NSNumber(value: jobId), forKey: "jobId")

```

But the best and recommended way is dot notation

```
object.jobId = jobId

```
You need to set `NSNumber` instead of `String`. Replace this line:

```
object.setValue("\(jobId)", forKey: "jobId")

```

with:

```
object.jobId = jobId

```