小编Dek*_*kso的帖子

Angular PrimeNG表使用cols数组为每列设置管道

我正在尝试用PrimeNG学习角度.这是链接https://primefaces.org/primeng/#/table.

是否可以使用管道阵列为每列包含管道?

在cols数组中,我想添加另一个这样的字段.

this.cols = [
    { field: 'vin', header: 'Vin', type: 'date' },
    { field: 'year', header: 'Year', type: 'number' },
    { field: 'brand', header: 'Brand', type: 'number' },
    { field: 'color', header: 'Color'}
];
Run Code Online (Sandbox Code Playgroud)

然后在模板中,我会像这样使用它

<tr>
    <td *ngFor="let col of columns">
        {{ col.type? rowData[col.field] | col.type : rowData[col.field]}}
    </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我试过这个,它给了我模板解析错误.

angular primeng-turbotable

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

用于Bigdecimal null验证的三元运算符

为什么我在这段代码中得到空指针异常?

    BigDecimal test = null;
    String data = "";
    try {
    System.out.println(test==null?"":test.toString());
    data = test==null?"":test.toString();
    System.out.println(data);
    data = data +  " " + test==null?"":test.toString(); // catching null pointer in this line
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

java ternary-operator nullpointerexception bigdecimal

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