AngularJS $ scope。$监视ng-repeat中的元素

时间:2014-10-22 21:59:25

标签: javascript angularjs

我在带有Angular的.haml文件中有以下代码:

  %li.dropdown{"ng-repeat" => "region in regions"}
        %a{:href => "#"}
          %input{:type => "checkbox", "ng-model" => "PODLocation", "ng-true-value" => "filter", "ng-false-value" => "noFilter"}/
          %span.lbl {{region.toUpperCase()}}

AngularJS控制器内的以下内容:

   $scope.regions = [
        'am',
        'cn',
        'uk',
        'au',
        'ru'
    ];


   # Controls when the user selects options from dropdown menu
    $scope.$watch 'PODLocation', (value) ->
        console.log "In Search Location Watch"
        console.log "Inside Watch"
        switch value
          when "filter"
            $scope.search.location = region
          when "no-filter"
            $scope.search.location = ""

但似乎无论我如何调试它,$ scope。$ watch在每次单击复选框时都不会被调用(IE:每次点击时都不显示Console.log消息)。此外,似乎我可以同时选择多个复选框(由于angular将它们绑定到相同的PODLocation变量,因此不应该出现。)

有没有人有任何想法如何解决这个问题?

0 个答案:

没有答案