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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Oh sorry I forgot to update the fiddle. Try on this link jsfiddle.net/enrique_alcantara/XmbHY/1
thanks, exactly what i needed. too bad i can't upvote yet. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.