NgModel Issue


#1

Hi,

I figured a problem in this while working in latest 1.0.0-beta.1 and 1.0.0-beta.

Code looks like this

<input type="text" class="form-control" ng-model="xyz"> <button class="btn btn-success" ng-click="enter()"> Save </button> $scope.enter = function() { console.log($scope.xyz); }

@maxtherocket Can you look into this ?

This same piece of code works in 0.9 versions.
Thanks
Gaurav


#2

You are running into an issue with 2 way binding. This is generally because of the different child and isolate scopes used in Ionic.

You need to be using “dot notation”. Here is a great resource that will help you understand : https://github.com/angular/angular.js/wiki/Understanding-Scopes

Here is a working example : http://plnkr.co/edit/RY3TOM


#3

Thanks @Calendee for replying.
Actually I have also solved this similarly, but the example I gave actually worked in plain AngularJs App and and 0.9 version of ionic.

See this http://plnkr.co/edit/hoEY7yl6xNmi6gGv5HvM?p=preview
So, why its not working in ionic latest version of 1.0 beta series.


#4

Ionic may have added a new isolate scope to any one of the Ionic directives. I don’t know exactly which one. In any case, it really is best practice to use Objects instead of primitives.