search

Home  >  Q&A  >  body text

angular.js - angular select problem

Now I have a problem. The value of Select is obtained remotely. The following is the json returned by the server

When I use ng-options to bind to select, the value of option is in the following format:

Why does it look like number: 1? How can I remove it?
In addition, how do I get the selected value after submitting the form?
Thank you everyone

某草草某草草2883 days ago650

reply all(2)I'll reply

  • 阿神

    阿神2017-05-15 17:11:42

    The first way to write it is like this

    <select ng-model="xxx" ng-options="item.name for item in fishBreed track by item.fish_breed_id"></select>

    What is taken out from ng-model is the object you selected. Two-way binding will bind the value through item.fish_breed_id

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-15 17:11:42

    js:$scope.toString = function(){

                                   list.id.toString();
                                }

    html: <option value="{{toString(x.id)}}" ng-repeat="x in list" ng-bind="x.name"></option>

    reply
    0
  • Cancelreply