How to assign selected option's text to another model while using ng-options?

前端 未结 3 588
情深已故
情深已故 2021-01-22 21:31

I can create a select tag and place data inside it. I can assign that select\'s selected option to a model but can\'t assign its text to another model.

Here is example b

3条回答
  •  一整个雨季
    2021-01-22 21:55

    Solution: Please Check this.This will resolve your problem Once you select from DROPDOWN the selected Object will be stored in customer. Then this customer object contains id as well as name

    MISTAKE you have made is

         ng-model="customerId"  ng-options="item.id as item.name for item in content"
    

    Here ONLY item.id will be collected to customerId

    If you want whole object then DO LIKE BELOW

        

提交回复
热议问题