当 ng-change 事件发生时,函数不会在角度 js 中调用



这是下面的代码,我已经研究了几个博客,但请注意找到了解决此问题的任何方法。

HTML 文件:-

<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');
  }
}])
我不知道

这是否只是剪切和粘贴或徒手输入的错误问题,但您的控制器格式不正确。你有一个额外的右括号(})在那里。试试这个:

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

最新更新