how to set default value after ng-options completed?

风格不统一 提交于 2019-12-24 07:49:54

问题


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>

来源:https://stackoverflow.com/questions/41493265/how-to-set-default-value-after-ng-options-completed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!