populating a select with options

6 views
Skip to first unread message

Les Stockton

unread,
Apr 20, 2018, 10:33:23 AM4/20/18
to Angular and AngularJS discussion
I'm new to Angular 5.  I created a service that successfully builds an observable option of array of type from my data model.  I've verified that I received data.
but I can't seem to populate a select with options.
To simplify things, I created an simple array in my typescript and try to use that in the option tag instead.  It still wont work.  So I must be something wrong.  Please help.

here's the definition of the array in typescript:

 classificiations = [
     { ClassificationId: null, Name: 'None' },
     { ClassificationId: '1', Name: 'Classifified' },
     { ClassificationId: '2', Name: 'Simsec' },
     { ClassificationId: '3', Name: 'Confidential' },
     { ClassificationId: '4', Name: 'Secret' },
     { ClassificationId: '5', Name: 'Top Secret' }];

and then here's the markup in html:

                         <select
                                    name="ddlRequestClassification2">
                          <option *ngFor="let itm of classifications"
                                      [value]="itm.ClassificationId">{{itm.Name}}</option>
                        </select>

I had referenced ngModel in the select, but took that out just to see if it would simplify things more, but that didn't improve things either.

Reply all
Reply to author
Forward
0 new messages