0

I'm trying to make a comparison of values to "check" an <option> tag inside of my <select> tag, but can't find a solution...

*This is an administration page, so I already have the {{x.nivel}} value. I just need to mark it as "selected" according to each "inscritos" from ng-repeat.

Help :\

            <li ng-repeat="x in inscritos | orderBy:'nome'">
                <select>
                    <option ng-selected="(this.value)=={{x.nivel}}" value="Iniciante">Iniciante</option>
                    <option ng-selected="(this.value)=={{x.nivel}}" value="Intermediário">Intermediário</option>
                    <option ng-selected="(this.value)=={{x.nivel}}" value="Avançado">Avançado</option>
                </select>
        </li>

1 Answer 1

2

Don't use {{}} in js expression:

 <li ng-repeat="x in inscritos | orderBy:'nome'">
    <select>
       <option ng-selected="x.nivel=='Iniciante'" value="Iniciante">Iniciante</option>
       <option ng-selected="x.nivel=='Intermediário'" value="Intermediário">Intermediário</option>
       <option ng-selected="x.nivel=='Avançado'" value="Avançado">Avançado</option>
     </select>
 </li>

The double curly brace notation {{ }} is used to bind values with html elements. See templates docs.

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

2 Comments

Hey, Lukasz, worked like a charm :) Thank you very much.
I'm glad that helped :)

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.