JavaScript ng-options will not pre-select an option

I am using angular's ng-options to populate the html with the names of people. I want it to pre-select the value that I have set as the ng-model (registrantSelected). But for some reason, it won't do so.

I have looked up various different documentations for ng-options and looked at a bunch of other stack overflow posts about ng-options, but I can't seem to figure out what I am doing wrong.

Code can be found in this plunker or below:

Javascript:

angular.module('app', [])
    .controller("MainController", ["$scope", function($scope) {
        $scope.paidDuesCompanyPeople = [{
            "FirstName": "Person",
            "LastName": "One",
            "MemberType": {
                "IsMember": false,
                "Name": "Non-member"
            }
        }, {
           "FirstName": "Second",
           "LastName": "Person",
           "MemberType": {
               "IsMember": true,
               "Name": "Member"
           }
        }, {
           "FirstName": "Three",
           "LastName": "People",
           "MemberType": {
               "IsMember": false,
               "Name": "Non-member"
        }
    }];

        $scope.registrantSelected = {
            "FirstName": "Person",
            "LastName": "One",
            "MemberType": {
                "IsMember": false,
                "Name": "Non-member"
            }
        };
    }]);

HTML:

<div ng-app="app" ng-controller="MainController">
  <div class="col-xs-12 col-sm-5">
    <form class="form-horizontal">
      <div class="form-group">
        <label class="col-sm-6 control-label">Registration for</label>
        <div class="col-sm-6">
          <select class="form-control" ng-model="registrantSelected" ng-options="person.FirstName + ' ' + person.LastName for person in paidDuesCompanyPeople">
          </select>
        </div>
      </div>
    </form>
  </div>

  {{registrantSelected}}
</div>

Thank you for any help you can give!

Answer:1

I'm trying to get some data from a MySQL table for the first time. I'm using ionic , PHP and AngularJS to try it but my query doesn't return anything. As I'm devloping it for my first time, I'm ...

I'm trying to get some data from a MySQL table for the first time. I'm using ionic , PHP and AngularJS to try it but my query doesn't return anything. As I'm devloping it for my first time, I'm ...

  1. mysql data with type
  2. mysql data at rest encryption
  3. mysql data to json
  4. mysql data to excel
  5. mysql.data for visual studio
  6. mysql data to file
  7. mysql.data in c#
  8. mysql data to php table
  9. mysql data to excel export
  10. mysql data in replication
  11. mysql data in where
  12. mysql data and count
  13. mysql data in folder
  14. mysql data to docker
  15. mysql data and structure
  16. mysql data types with examples
  17. mysql data type with decimal
  18. mysql data types with size
  19. get mysql data with javascript
  20. get mysql data with php

In JavaScript, I have the following Sets: var mySet = new Set(["foo", "bar", "baz"]); var valuesToRemove = new Set(["foo", "baz"]); I need a function that removes a set of values: removeAll(mySet, ...

In JavaScript, I have the following Sets: var mySet = new Set(["foo", "bar", "baz"]); var valuesToRemove = new Set(["foo", "baz"]); I need a function that removes a set of values: removeAll(mySet, ...

  1. remove existing values
  2. php array remove existing values

I have a MongoDB database with many documents in a collection. Each of those articles has a field called myField containing a string. Is it possible for me to run a bulk update on all documents in ...

I have a MongoDB database with many documents in a collection. Each of those articles has a field called myField containing a string. Is it possible for me to run a bulk update on all documents in ...

  1. mongodb update string to date
  2. mongodb update string to objectid
  3. mongodb update string to int
  4. mongodb update string replace
  5. mongodb update string to array
  6. mongodb update string append
  7. mongodb update string to number
  8. mongodb update string
  9. mongodb update concat string
  10. mongodb update convert string to date
  11. mongodb update part of string
  12. mongodb update field append string

I'm following the example exactly as shown in https://github.com/marcshilling/react-native-image-picker using react-native-image-picker, via terminal with react-native run-ios and coding via Atom ...

I'm following the example exactly as shown in https://github.com/marcshilling/react-native-image-picker using react-native-image-picker, via terminal with react-native run-ios and coding via Atom ...

  1. react native image picker
  2. react native image background
  3. react native image resizemode
  4. react native image crop picker
  5. react native image cache
  6. react native image not showing
  7. react native image gallery
  8. react native image viewer
  9. react native image upload
  10. react native image onpress
  11. react native image svg
  12. react native image editor
  13. react native image carousel
  14. react native image zoom
  15. react native image resize
  16. react native image slider
  17. react native image button
  18. react native image base64
  19. react native image loading
  20. react native image view