how to use ng-option to set default value of select element

前端 未结 12 812
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 11:07

I\'ve seen the documentation of the Angular select directive here: http://docs.angularjs.org/api/ng.directive:select. I can\'t figure how to set the default value. This is

12条回答
  •  梦谈多话
    2020-11-22 12:11

    The ng-model attribute sets the selected option and also allows you to pipe a filter like orderBy:orderModel.value

    index.html

    
    

    controllers.js

    $scope.orderOptions = [
        {"name":"Newest","value":"age"},
        {"name":"Alphabetical","value":"name"}
    ];
    
    $scope.orderModel = $scope.orderOptions[0];
    

提交回复
热议问题