简体   繁体   中英

Function is not calling in angular js when ng-change event occurs

Here is the code below i have studied several blogs but note found any way to resolve this problem.

HTML File:-

<ion-content ng-controller="IpScanner">
  <div class="list">
    <div class="item item-input-inset">
      <label class="item-input-wrapper">
        <input type="text" placeholder="Barcode"  ng-model="IpValue" ng-change="CartAction()" >
      </label>
    </div>
  </div>
</ion-content>

JSFile

.controller('IpScanner', ['$scope', 'socket', function($scope, socket, $window, $timeout, $ionicPopup, $q) {
  $scope.CartAction = function() {
    window.alert('Onchange');
  }
}])

I don't know if this was just a matter of bad cut and paste or freehand typing in, but your controller is not well-formed. You have an extra closing bracket ( } ) in there. Try this:

.controller('IpScanner', ['$scope', 'socket', '$window', '$timeout', '$ionicPopup', '$q', function($scope, socket, $window, $timeout, $ionicPopup, $q) {
    $scope.CartAction = function()
    {
        window.alert('Onchange');
    }
}]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM