@zhouhaowowtv wrote:
I have a select element to select gender.
<select ng-model="data.user.gender"> <option ng-repeat="gender in genders" ng-value="{{gender.value}}" ng-selected="gender.value == data.user.gender">{{gender.text}}</option> </select>
My controller:
$scope.data = {}; $scope.data.user = getCurrentUser(); $scope.genders = [ { value: 0, text: "Male" }, { value: 1, text: "Female" } ];
My problem is the default selected element is empty. My getCurrentUser() guarantee return an user object like this:
{ fullname: 'abc', email: 'my@email.com', gender: 0 }
The gender will be 0 or 1. But my select element is always blank when the page loaded no matter what gender value is.
Any suggestion? Thanks.
Posts: 1
Participants: 1