【问题标题】:Update Scope by selecting checkboxes通过选中复选框更新范围
【发布时间】:2015-01-15 03:14:05
【问题描述】:

我有两个表格,我想通过在表格行中使用单个选择下拉菜单或通过选择多个复选框并批量更新范围来过滤它们。

用户应该能够检查记录,选择顶部的下拉状态,然后更新范围。如果状态大于或等于 1,则进入一个表,如果小于,则进入另一个表。

小提琴http://jsfiddle.net/TheFiddler/hxz06sd7/

如何使用复选框根据选定的值更新选中的值?

选择

 <select ng-options="item.value as item.displayName for item in StatusDropDown" ng-model="person.status" ng-change="updateSelected()"></select>

updatedSelected 应该采用选中的行和过滤器:

$scope.updateSelected = function(statusarg){
            //how to set status for selected and update tables

}

【问题讨论】:

  • 不应该把小提琴放在评论里。 :) 既然您已经弄清楚了原始问题的大部分内容。你最初的问题太宽泛了。我已将 ng-model 放在这些复选框中,单击保存时只需过滤人员以获取选中的人。

标签: javascript angularjs angularjs-scope angularjs-ng-model


【解决方案1】:

将 ng-model (person.selected) 与复选框和 on-change 相关联,根据所选属性将其过滤掉,然后将 value 应用于它们。

$scope.updateSelected = function (statusarg) {
    //how to set status for selected and update tables
    angular.forEach($scope.people, function(person){
        person.selected && (person.status = statusarg);
    });
}

Fiddle

您的代码的早期问题是:您不应该使用 track byselect as 语法,它们不能一起工作。您很少需要通过 ng-options 使用 track by。 Read this了解更多详情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-21
    • 1970-01-01
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多