0

I have dropdown directive here LINK

Need some assistance on how can I bind for my edit and save form.

FOR VIEWING/EDIT: How can I assign my supplier.statusID in my keyword directive?

<tr ng-repeat="supplier in suppliers">
     <td>{{supplier.Id}}</td>                
     <td>{{supplier.Name}}</td>                
     <td>
        <keywords title="Choose Status" label="" array="myKeyword" opt-value="Id" opt-description="Description"></keywords>
        <br />
     </td>
</tr>

FOR ADD NEW RECORD: how can I save the ID of my keyword directive to my supplier.statusID

<div>Name: <input type="text" />
   <br />
   Status: <keywords title="Choose Status" label="" array="myKeyword" opt-value="Id" opt-description="Description"></keywords><br><button>Save</button>
</div>

1 Answer 1

1

You just need to create a new property called supplierId in your directive's scope and assign the supplier's ID to that property where you declare the directive

app.directive('keywords', function(){
    return {
        restrict: 'E',
        scope: {
            array: '=',
            supplierId : '='
        },
        template:   '<label>{{label}}</label>' +
                    '<select ng-model="supplierId" ng-options="a[optValue] as a[optDescription] for a in array">'...

In the markup

<td><keywords title="Choose Status" label="" array="myKeyword" opt-value="Id" 
      supplier-id="supplier.Id" opt-description="Description"></keywords>
                    <br />
                </td>

I forked your fiddle and make it work

http://jsfiddle.net/XmbHY/

I hope this helps.

3
  • thanks but the jsfiddle you include doesn't show the changes you made. I still have problem auto-selecting the dropdownlist when the supplierID is applied. Commented Sep 3, 2013 at 17:36
  • Oh sorry I forgot to update the fiddle. Try on this link jsfiddle.net/enrique_alcantara/XmbHY/1 Commented Sep 3, 2013 at 18:00
  • thanks, exactly what i needed. too bad i can't upvote yet. :) Commented Sep 3, 2013 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.