我有一个这样的数组:
documents = [
{ code: 'TEST 1', mandatory: true},
{ code: 'TEST 2', mandatory: true},
{ code: 'TEST 3', mandatory: false},
{ code: 'TEST 5', mandatory: false},
];
在 html 模板中我有这个循环:
<li class="list-group-item" *ngFor="let document of documents">
<span>{{document.code}}</span>
</li>
我有一个这样的常量:
const mandatory = true;
我需要遍历文档,只显示必填项为 TRUE 的文档。我知道我可以在 JavaScript 代码中进行过滤,但我需要在 html 模板中进行。