Issue with model binding when using ionic


#1

i have the following code: and the data binding is not working when using ionic. if you copy and paste this code in plunker you will see that on every key entry it will clear the input. This is not the case when using ionic. Has anyone had a similar issue?

<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Example - example-ngChange-directive-production</title>


  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.2/angular.min.js"></script>



</head>

<body ng-app="">
  <script>
    function Controller($scope) {
      tester = ["d", "d", "dfsd"];
      $scope.me = "me";
      $scope.testing = tester;
      $scope.counter = 0;
      $scope.change = function() {
        $scope.counter++;
        tester.push($scope.confirmed.stuff);
        $scope.confirmed = '';
      };
    }
  </script>
  <div ng-controller="Controller">
    <input type="text" ng-model="confirmed.stuff" ng-change="change()" id="ng-change-example1" />
    <label for="ng-change-example2">Confirmed</label>
    <br />
    <tt>debug = {{confirmed}}</tt>
    <br/>
    <tt>counter = {{counter}}</tt>
    <br/>
    <div ng-repeat="test in testing track by $index">{{test}}</div>

  </div>
</body>

</html>

Problem with Pull To Refresh
#2

Ionic uses child scopes and isolate scopes quite frequently. Because of this, you will often not get 2 way binding on primities. You need to be using “dot notation”.





Is ng-model different with ionic? Maybe scope bug?
#3

Thank you. Such a simple mistake on my part. WORKED!!!


#5

I have opened up a separate topic for this, but it seems the solution above works only if the input type is text. It doesn’t seem to work when the type is email?