Angular ui-select: How to bind only selected value to ng-model

后端 未结 4 2275
借酒劲吻你
借酒劲吻你 2021-02-19 18:43
$scope.property = new Property();
$scope.property.propertyType = {};

$scope.propertyTypes = [
    { value: \'ResidentialPlot\', name: \'Residential Plot\' },
    { valu         


        
4条回答
  •  无人共我
    2021-02-19 19:10

    I had the same problem. I looked up the documentation in:

    https://github.com/angular-ui/ui-select/wiki/ui-select-choices

    The best way to do this is:

    {{$select.selected.name}}

    Note how we are able to specify value.id in repeat while still using value.name for what is shown within the combo box. This will work with ng-model being set to the value.id (whatever was saved).

    I verified this works for me. Posting here because Google brings people to this page.

提交回复
热议问题