12345678910111213141516171819 |
- this.checkableData = [{ key: 1 }, { key: 2 }, { key: 3 }, { key: 4 }];
- this.keyProp = "key";
- this.checked = [1, 2];
- let checkableDataKeys = this.checkableData.map(item => {
- let keyProps = {};
- keyProps[item[this.keyProp]] = true;
- return keyProps;
- });
- console.log(checkableDataKeys);
- this.checked.every(item => {
- console.log(checkableDataKeys[item]);
- return checkableDataKeys[item];
- });
- this.allChecked =
- checkableDataKeys.length > 0 &&
- this.checked.length > 0 &&
- this.checked.every(item => checkableDataKeys[item]);
|