Pregunta

I'm trying to do something I've done several times in the current project, but somehow it won't work now.

I have an array with objects in it:

$scope.teacherList = [
    {"id":1,"firstName":"Dave","lastName":"Squarepants"},   
    {"id":2,"firstName":"Patrick","lastName":"Star"}
]

Now I make a select box with ng-options:

<select name="teacher" ng-model="crudTeacher.teacher.id" 
                       ng-options="teacher.id as teacher.firstName + ' ' + 
                                   teacher.lastName for teacher in teacherList" required>
</select>

But when I look at the values, ist just 0 and 1, even if the id's are 1 and 2.

Angular somehow doesn't take the teacher.id as ... part correctly.

Have I missed something?

¿Fue útil?

Solución

According to my sample , it does display the correct values :

http://jsbin.com/quhigumu/2/edit

enter image description here

enter image description here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top