Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度:检查更改结果_Angular_Angular8 - Fatal编程技术网

Angular 角度:检查更改结果

Angular 角度:检查更改结果,angular,angular8,Angular,Angular8,我想更改depositTasks的字段选中时的结果,如果depositTasks的某些字段选中时的结果为假,则另一个结果为假 app.html <input type="checkbox" [(ngModel)]="task.checked" (click)="changChecked(task.checked)" [ngModelOptions]="{standalone: true}"> 对不起,

我想更改depositTasks的字段选中时的结果,如果depositTasks的某些字段选中时的结果为假,则另一个结果为假

app.html

<input type="checkbox" [(ngModel)]="task.checked" (click)="changChecked(task.checked)"
 [ngModelOptions]="{standalone: true}">

对不起,你的目标是什么还不清楚。以下是如何确定是否选中所有复选框的解决方案:

HTML

<input type="checkbox" [(ngModel)]="task.checked" (change)="onChange()"
 [ngModelOptions]="{standalone: true}">

我的目标是当所有复选框都选中时:true以执行此操作。onSelectedStatus('Resolved')但如果选中所有复选框:false以执行此操作。onSelectedStatus('Assigned')好的,我根据您的需要调整了代码。如果合适,请将此答案标记为解决方案。Thx提前。
<input type="checkbox" [(ngModel)]="task.checked" (change)="onChange()"
 [ngModelOptions]="{standalone: true}">
onChange(): void {
    if (this.depositTasks) {
        // when there is no element with checked state of false, the result is -1
        // and when the result is -1 our comparison returns true
        const allChecked = (this.depositTasks.findIndex(task => task.checked === false) === -1);

        if (allChecked) {
            this.onSelectedStatus('Resolved');
        } else {
            this.onSelectedStatus('Assigned');
        }
    }      
}