无法在 ngRepeat 中使用 ngChange - Angularjs

Can't use ngChange in ngRepeat - Angularjs

我正在使用 ngRepeat 生成一个复选框字段集。

我是这样操作的:

<fieldset id="country_select" ng-controller="CountriesListController">
        <span ng-repeat="country in countries">
          <label>
            <input type="checkbox" id="country.name" ng-change="locationAdd(country.name)">
            {{country.name}}
          </label><br/>
        </span>
</fieldset>

但是由于某种原因,将 ngChange 指令添加到我的复选框会导致我的 ng-repeat 输出仅显示一个复选框,如下所示:

复选框 {{country.name}}

当我将 ngChange 更改为 ngClick 时,我的 ngRepeat 循环起作用了。

所以我的问题是:为什么 ngChange 不能与 ngRepeat 一起使用,而 ngClick 在插入我的复选框输入时可以使用

我的控制台出现以下错误:

Error: [$compile:ctreq] Controller 'ngModel', required by directive 'ngChange', can't be found!
http://errors.angularjs.org/1.3.7/$compile/ctreq?p0=ngModel&p1=ngChange
at REGEX_STRING_REGEXP (http://localhost:9000/bower_components/angular/angular.js:63:12)
at getControllers (http://localhost:9000/bower_components/angular/angular.js:7535:19)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7724:33)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7073:13)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7076:13)
at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7076:13)
at publicLinkFn (http://localhost:9000/bower_components/angular/angular.js:6952:30)
at $get.boundTranscludeFn (http://localhost:9000/bower_components/angular/angular.js:7091:16)
at controllersBoundTransclude (http://localhost:9000/bower_components/angular/angular.js:7747:18)
at ngRepeatAction (http://localhost:9000/bower_components/angular/angular.js:24524:15)angular.js:11592 (anonymous function)angular.js:8542 $getangular.js:14241 $get.Scope.$digestangular.js:14486 $get.Scope.$applyangular.js:9644 doneangular.js:9834 completeRequestangular.js:9775 requestLoaded

ng-change 将需要 ng-model。您在复选框

上缺少 ng-model

检查此 plunker 以获取工作示例。

请注意您打算使用 ngChange。就我而言,我的手指和眼睛有点太快了,当我打算使用 data-ng-click

时,没有发现 Intellisense 选择 data-ng-change

我很确定我在输入 data-ng-c 后只看到一个条目 (data-ng-click);但也许 Intellisense 在显示其他选项时有点慢,当我点击 [Tab] 时首先选择字母顺序...