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年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...