angular.js - Questions about angular's select
高洛峰
高洛峰 2017-05-15 17:10:37
0
1
557

js part:

$scope.sex = [{'name':'男', 'value':'man'},{'name':'女', 'value':'women'}];

html part:

<select ng-model="sexOptions" ng-options="x.value as x.name for x in sex">
    <option value="">请选择</option>
</select>

The problem I am encountering now is:
I obtained the data results from the server. If the user's profile is "male", then this select must select the male item

This is how I bound it

$scope.sexOptions = {'value':res.farmersInfo.sex};

As shown below:

Binding can now be achieved, but when I select the option again, for example, I select the gender as female:
As shown below:

The problem arises, I selected female, but the default "Please select" is displayed

How to solve this problem?
Thank you everyone! ! ! !
Very anxious!

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
滿天的星座

<select ng-model="sexOptions.value"> try this?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template