【问题标题】:AngularJS ng-change not workingAngularJS ng-change 不起作用
【发布时间】:2017-03-13 06:09:01
【问题描述】:

我主要使用 ng-change 但这次 ng-change 不会触发它也有 ng-model 并且它在我的应用程序和控制器中。我在其他 ng-change 中使用的语法相同。我调试了 3 天,但仍然找不到解决方案。

这是输入:

 <input type="text" class="form-control" ng-change="search()" ng-model="count_time">

这里是控制器:

var app = angular.module("myCurriform", []);


    app.controller("standardCtrl", function($scope,$http,$filter,$location,$window) {


      $scope.search = function() {
        console.log($scope.count_time);



      };


    });

【问题讨论】:

  • 您在控制台中看到任何错误吗?
  • 无。没有错误。我的控制台像白色一样干净
  • 发布你的整个 html 文件
  • 无法发布,因为我的 html 文件中有太多代码行

标签: html angularjs angular-ngmodel


【解决方案1】:

在控制器中使用观察者功能

<input type="text" class="form-control" ng-model="count_time">

JS:

$scope.$watch('count_time', function() {
  $scope.search();
});

【讨论】:

  • 然后创建 jsfiddle 代码进行调试,因为它对我有用。
猜你喜欢
  • 2016-11-04
  • 1970-01-01
  • 1970-01-01
  • 2018-01-22
  • 1970-01-01
  • 1970-01-01
  • 2016-08-17
  • 2018-03-11
  • 1970-01-01
相关资源
最近更新 更多