Select model not bind in ion content

The problem occurs with the following ionic code:

<ion-content class="has-logo has-footer">
    <ion-item class='item-no-border'>
            <!-- ng-select gender -->
            <select ng-model="prefGender" ng-options=" for gender in preferences.gender">


And the following is the controller data:

$scope.preferences = {gender: [ {selected: true, name : "Man", value: 1}, {selected: true, name : "Woman", value: 2} ]};
$scope.prefGender = $scope.preferences.gender[0];

When i select between option the ng-model ‘prefGender’ in the view work and {{}} change the value but inside the controller the ‘prefGender’ does not change and keep the initial value. The problem disappear when i remove all the ion tag (ion-view, ion-content, ion-item) in the html.

Could anyone help me to solve this problem,please?

Hey soo not sure what I should be looking at, seems to work for me.

What part isn’t working exactly? Your description seems a bit vague.

Yes it seem to work well from the view but inside the controller the model doesn’t change. You can check this . When click the check button the value keep the same.

So the problem is when access the model inside the controller it keeps the initial value, and it will work after remove the tag “ion-content”

Is there any way to fix it or tricks to overcome this problem? Please help me!

Hmm, I think its the way you have the select set up, take a look at this example.

Now the model updates correctly

I have found the trick to overcome this problem. Because the model change only in the view so i pass that changed value to controller through ng-change : .
But i pretty sure that there is some problem with the ionic directive, i think it is not two way binding in this case because without ‘ion-content’ tag it works correctly (no need ng-change).

Please help me. Now i have the reversed problem, i want to change the selected option from the controller but the view only change for the first time . And one a again, it works correctly when remove the ‘ion-content’ tag :frowning: . Is there any way to fix this problem completely?

Again, I think its the way you have yours set up.

I will try your way but i think my setup isn’t the problem because it is simple and follow exactly AngularJs instruction . And i find out that not only the select menu but also other form elements get this issue, i also get this issue with the text input

Your solution just work with the simple model. In case of the more complex model it does not work

I’m sorry your code is not complex, but its a mess,…
I don’t know why you are using value prop as it seems you don’t use it anywhere.
First of all I don’t get the Check function as it checks a hard coded value prop that never changes,
you never set this $scope.prefGender.value the only thing that is changing is $scope.prefGender.gender so you should check that. Also I don’t get why are you even using values in the array as your ng-value attributes is using

@ho_oh So I cleaned up mhartingtons example, how it should be, anyway you had issue with inherited scope this usually happens when there is another directive between your controller and select,input, etc. What you should usually do is declare variable inside another object so its more explicit.
Check the example:


Select behavior seems to have changed in Ionic. I tried directives from angular without success.

Your old example on codepen doesn’t seem to work. Can you please update based on your availability?