小编blu*_*oud的帖子

如何在更改mat-checkbox时停止在调用函数时的事件传播?

<mat-checkbox (change)="handleProductClick(children, $event)"  [(ngModel)] = "children.selected"
[name]="children.grpId" [id]="children.id"></mat-checkbox>

handleProductClick(selectedProd : Product, event: any)
{
  event.stopPropagation();
}
Run Code Online (Sandbox Code Playgroud)

如果我使用单击功能而不是更改,则可以正常工作。虽然我无法使用click。我必须坚持改变。有没有办法从change函数调用stopPropagation?如果不是,我还能做些什么来阻止事件传播?

onchange event-propagation

3
推荐指数
1
解决办法
1418
查看次数

查找数组中最小值和最大值的有效方法

我想找出整数数组中的最小值和最大值.

以下哪种方式效率更高?

  1. 对数组进行排序,然后查看开始和结束以获得最小值和最大值.

  2. 使用Arrays.asList()然后使用该Collections.min()方法将数组转换为列表.

我想要使​​用它的代码如下:

// Find missing number from an array of consecutive numbers arranged randomly
import java.util.Arrays;

public class MissingNumber {

    public static void main(String[] args) {

        int[] consecutiveRandomNos = { 3, 6, 5 };

        System.out.println(addNumbers(consecutiveRandomNos));
        System.out.println("The missing number is "
                        + (returnSum(consecutiveRandomNos) - addNumbers(consecutiveRandomNos)));
    }

    public static int addNumbers(int... numbers) {
        int result = 0;

        for (int number : numbers) {
            result += number;
        }

        return result;
    }

    public static int returnSum(int... nos) …
Run Code Online (Sandbox Code Playgroud)

java arrays sorting max min

2
推荐指数
1
解决办法
9259
查看次数

标签 统计

arrays ×1

event-propagation ×1

java ×1

max ×1

min ×1

onchange ×1

sorting ×1