search

Home  >  Q&A  >  body text

angular.js - Some parameters of angular's ng-option option.id as option.title The as in this is

What does as mean in the following code?

ng-options="option.id as option.title for option in curOptionArray"
给我你的怀抱给我你的怀抱2867 days ago659

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-05-15 17:04:25

    option.id means selected,
    option.title means displayed,
    as is for this purpose

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-15 17:04:25

    It can be understood as an ng syntax option.id is the value submitted by select option.title is the value displayed by select option represents the current element in the array curOptionArray

    reply
    0
  • 迷茫

    迷茫2017-05-15 17:04:25

    Please refer to the official website:
    https://docs.angularjs.org/api/ng/directive/ngOptions#!

    There is an example:

    $scope.items = [{
      id: 1,
      label: 'aLabel',
      subItem: { name: 'aSubItem' }
    }, {
      id: 2,
      label: 'bLabel',
      subItem: { name: 'bSubItem' }
    }];
    
    <select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>

    reply
    0
  • PHPz

    PHPz2017-05-15 17:04:25

    You can check out Hacking with Angular: Playing with the ngOptions directive

    reply
    0
  • Cancelreply