David Tunnell
David Tunnell

Reputation: 7542

Passing actual object to function on event

I have a button that when pressed I need to pass the object 'contract' into.

                <td class="col-md-1" colspan="1" style="text-align: center; vertical-align: middle;">
                    <button class="btn btn-primary" data-ng-click="removeContract(ctrl.selectValue, contractIndex)">    &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;<     &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;</button>
                </td>
                <td class="col-md-5" colspan="5">
                    <label class="control-label">{{item.fields[132].displayName}}</label>
                    <select size="5" ng-model="ctrl.selectValue">
                        <option data-ng-repeat="contract in contracts" value="{{contract}}">{{contract.CONT_ORDNO}} - {{contract.SUPP_NAME}}[{{contract.SUPP_NUM}}]</option>
                    </select> 
                </td>     

The object is being passed but it is a string of the object, not the object itself:

enter image description here

I'm aware I could convert it after, but the way the app was designed it's supposed to be the object.

How do I pass the actual object?

Upvotes: 0

Views: 35

Answers (1)

Sergey Krivov
Sergey Krivov

Reputation: 372

Use this construction:

<select size="5" ng-model="ctrl.selectValue" ng-options="(contract.CONT_ORDNO + ' - ' + contract.SUPP_NAME + '[' + contract.SUPP_NUM + ']') for contract in contracts">
</select>

Upvotes: 1

Related Questions