before i start I have tried the following
https://www.angularjswiki.com/angular/how-to-bind-a-select-element-to-object-in-angular/ https://www.codeproject.com/Questions/1278097/How-do-you-get-the-value-of-the-selected-option-in Associate select value to ngModel in Angular 4 How to assign selected value to "Select" when value is of class object in angular 2_ https://docs.angularjs.org/api/ng/directive/select
something so easy to do in PHP has taken me 8 hours and I am still not even close. I do not understand what I am doing wrong here?
TS file
shopstates: any = {};
selectedObject: any;
this.shopstates = [
{ statename: 'Australian Capital Territory', statecode: 'ACT' },
{ statename: 'New South Wales', statecode: 'NSW' },
{ statename: 'South Australia', statecode: 'SA' },
{ statename: 'Queensland', statecode: 'QLD' }
];
component html file
<select [(ngModel)]="selectedObject" class="form-control" (change)=consoleLog()>
<option *ngFor="let state of shopstates" [ngValue]="state">{{ state.statename }} ({{ state.statecode }})</option>
</select>
Selected State is {{ selectedObject.state }}
this is very frustrating. I'm about to make a change to try and pass the value to the TS file but I don't want to do this and 2. don't know how to pass the value anyway
Any direction or help is appreciated