how to set default value after ng-options completed?

48 views Asked by At

assume that this is my controller:

function MainController(BaseInformation, baseInformationConstants) {
    var vm = this;
    getGenders();

    function getGenders() {
        vm.genders = BaseInformation.list({headerId: baseInformationConstants.genderId});
    }
}

and this select tag, that i want to set default value for it with ng-init, but it didn't worked:

<select ng-init="vm.user.genderId = {id: vm.genders[0].id}"
        ng-model="vm.user.genderId"
        ng-options="gender.id as gender.topic for gender in vm.genders track by gender.id">
</select>
0

There are 0 answers