Kwnstantinos Natsios Kwnstantinos Natsios - 1 month ago 11
AngularJS Question

Angular 1.5 Option with ng-change

We have this JSON

{
"Day": "Monday",
"Start_Time": "08:00"
},
{
"Day": "Tuesday",
"Start_Time": "10:00"
},
{
"Day": "Thursday",
"Start_Time": "08:00"
}


So I'm trying to make these days appear inside an html
select
item with those options. Something like this

<select>
<option>Monday 08:00</option>
<option>Tuesday 10:00</option>
<option>Thursday 08:00</option>
</select>


And when the user changes the option i would like to print out the new option that he made, here i'm stuck.

What I've done till now.

<select ng-if="student.diwro" >
<option ng-repeat="x in modules" ng-selected="student.diwro == x.Anatheseis_Id" >{{x.Day}} {{x.Start_Time}}</option>
</select>


But html element
option
has no
ng-change
.

Any idea of how can I console log the changed day ?

Thanks a lot!

Answer
<select ng-if="student.diwro" ng-change="change()" ng-model="selectedValue">
    <option ng-repeat="x in modules" ng-selected="student.diwro == x.Anatheseis_Id" >{{x.Day}} {{x.Start_Time}}</option>
</select>