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

Method constructor

src/aria/tabs/tab-list.ts:132–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 });
131
132 constructor() {
133 afterNextRender(() => {
134 this._collection.startObserving(this.element);
135 });
136
137 afterRenderEffect(() => {
138 this._pattern.setDefaultStateEffect();
139 });
140
141 // This needs to be in an afterRenderEffect to ensure the tabs have all been initialized.
142 // Otherwise, the lookup here can fail and it does not get re-run afterwards.
143 afterRenderEffect({
144 write: () => {
145 const pattern = this._selectedTabPattern();
146 const tab = this._collection.orderedItems().find(tab => tab._pattern == pattern);
147 this.selectedTab.set(tab?.value());
148 },
149 });
150
151 // Check for any violations after the DOM has been updated.
152 if (typeof ngDevMode === 'undefined' || ngDevMode) {
153 afterRenderEffect({
154 read: () => {
155 const violations: string[] = [];
156
157 const values = this._collection.orderedItems().map(t => t.value());
158 const duplicates = values.filter((item, index) => values.indexOf(item) !== index);
159 if (duplicates.length > 0) {
160 violations.push(`Duplicate value '${duplicates[0]}' detected inside ngTabList.`);
161 }
162
163 reportViolations(violations, this.element);
164 },
165 });
166 }
167 }
168
169 ngOnInit() {
170 this._tabsParent._register(this);

Callers

nothing calls this directly

Calls 7

reportViolationsFunction · 0.90
startObservingMethod · 0.80
setMethod · 0.80
pushMethod · 0.65
setDefaultStateEffectMethod · 0.45
valueMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected