MCPcopy Index your code
hub / github.com/angular/components / addChild

Method addChild

src/cdk/tree/tree.spec.ts:1579–1596  ·  view source on GitHub ↗
(parent: TestData, isFlat: boolean = true)

Source from the content-addressed store, hash-verified

1577 }
1578
1579 addChild(parent: TestData, isFlat: boolean = true) {
1580 const nextIndex = ++this.dataIndex;
1581 const child = new TestData(
1582 `topping_${nextIndex}`,
1583 `cheese_${nextIndex}`,
1584 `base_${nextIndex}`,
1585 parent.level + 1,
1586 );
1587 parent.children.push(child);
1588 if (isFlat) {
1589 let copiedData = this.data.slice();
1590 copiedData.splice(this.data.indexOf(parent) + 1, 0, child);
1591 this.data = copiedData;
1592 } else {
1593 parent.observableChildren.next(parent.children);
1594 }
1595 return child;
1596 }
1597
1598 addData(level: number = 1): TestData {
1599 const nextIndex = ++this.dataIndex;

Callers 4

constructorMethod · 0.95
tree.spec.tsFile · 0.45
mutateChildrenFunction · 0.45

Calls 2

pushMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected