0

I have been able to get the default value selected using the below. However, I am not sure how to set the value to the one previously selcted by the user for the object they are reviewing. If the default value matches their selection, then great it is fine. However, if the default is different how can I make sure the select is showing the item that that they picked? For example, they have selected item [2] in the drop down not the default [0]

<div class="container-fluid">
select ng-init="part.PartType = partTypes[0]" class="form-control" data-ng-model="part.PartType" data-ng-options="p for p in partTypes" required></select>
</div>

I wouldn't doubt there was something obvious I am missing. I am just not sure what to set in order to display the previously selected value that is being returned from the db.

Any suggestions would be greatly appreciated.

Thanks, S.

3
  • 1
    Why not set the default value in the controller? Commented Mar 23, 2015 at 14:33
  • Set value of ng-model variable to your selected item. Commented Mar 23, 2015 at 14:35
  • Thanks guys I will try that. I am new to Angular and figured I was missing something obvious. I will give that a shot. Commented Mar 23, 2015 at 14:36

1 Answer 1

1

Angularjs is 2 way bounded as in variables you should be able to set it in the controller

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

Comments

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.