Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Default value of select is not correct

$
0
0

@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

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>