What are the differences between ng-repeat and ng-options and why do they not behave the same way?

后端 未结 5 986
盖世英雄少女心
盖世英雄少女心 2020-11-27 20:31

How do ng-options and ng-repeat differ?

In the following code, I have an ng-repeat that iterates through a list of people:

5条回答
  •  抹茶落季
    2020-11-27 20:36

    ng-repeat give problem while send information back to controller because in general we show name to the user but use ID/Index of the option for backend operations.

    Simple words- with ng-options you may use complete JavaScript object.

    
    
    
    
    
    
    {{selectedName}} {{selectedName.age}}

    but with ng-repeat you have to deals with string.

    
    
    
    
    
    
    {{selectedName}} {{selectedName.age}}

    This example shows how to fill a dropdown list using the ng-repeat directive.

提交回复
热议问题