1

Using ng-repeat how to show default selected value using angularjs

my code : I have currencies :

"currencies":["AWG","BAM","BBD","BDT","BGN","BHD"]

selected currency is "BBD"

In my HTML

<select ng-init='toCurrencyCode = currency.toCurrencyCode' ng-model= 'toCurrencyCode' ng-options="toCurrencyCode as code for code in currencies">

</select>

If I wrote like this means last value as selected by default. I need exact selected currency. Please update your idea. Thanks in advance.

0

1 Answer 1

3

http://plnkr.co/edit/lSu1M58gMtqlOCsaCCrG?p=preview

 <select ng-init='toCurrencyCode = currency.toCurrencyCode' ng-model= 'toCurrencyCode' 
 ng-options="code for code in currencies">
Sign up to request clarification or add additional context in comments.

9 Comments

Hi this is fine. But if we are using with in ng-repeat means that selected value is not showing. Can u help me for this.
@Sangeetha.V do you want to use ng-repeat inside select ?
No. select is used inside of ng-repeat. Already am displaying one row using ng-repeat. With in that row i need this select. please help me for this.
@Sangeetha.V more likely that happens ng-repeat is creating separate scope for each row. It is difficult to help you without code can you please update my plunker and I will help you
plnkr.co/edit/lSu1M58gMtqlOCsaCCrG?p=preview I updated my problem here.. please check..
|

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.