MCPcopy Index your code
hub / github.com/angular/angular / init

Function init

modules/benchmarks/src/styling/ng2/init.ts:15–91  ·  view source on GitHub ↗
(moduleRef: NgModuleRef<StylingModule>)

Source from the content-addressed store, hash-verified

13import {StylingModule} from './styling';
14
15export function init(moduleRef: NgModuleRef<StylingModule>) {
16 const injector = moduleRef.injector;
17 const appRef = injector.get(ApplicationRef);
18 const componentRef = appRef.components[0];
19 const component = componentRef.instance;
20 const componentHostEl = componentRef.location.nativeElement;
21 const select = document.querySelector('#scenario-select')! as HTMLSelectElement;
22
23 const empty: number[] = [];
24 const items: number[] = [];
25
26 function create(tplRefIdx: number) {
27 component.tplRefIdx = tplRefIdx;
28 component.data = items;
29 appRef.tick();
30 }
31
32 function destroy() {
33 component.data = empty;
34 appRef.tick();
35 }
36
37 function update() {
38 component.exp = component.exp === 'bar' ? 'baz' : 'bar';
39 appRef.tick();
40 }
41
42 function detectChanges() {
43 appRef.tick();
44 }
45
46 function modifyExternally() {
47 const buttonEls = componentHostEl.querySelectorAll('button') as HTMLButtonElement[];
48 buttonEls.forEach((buttonEl: HTMLButtonElement) => {
49 const cl = buttonEl.classList;
50 if (cl.contains('external')) {
51 cl.remove('external');
52 } else {
53 cl.add('external');
54 }
55 });
56 }
57
58 for (let i = 0; i < 2000; i++) {
59 items.push(i);
60 }
61
62 bindAction('#create', () => create(select.selectedIndex));
63 bindAction('#update', update);
64 bindAction('#detect_changes', detectChanges);
65 bindAction('#destroy', destroy);
66 bindAction(
67 '#profile_update',
68 profile(
69 () => {
70 for (let i = 0; i < 10; i++) {
71 update();
72 }

Callers

nothing calls this directly

Calls 7

bindActionFunction · 0.90
profileFunction · 0.90
createFunction · 0.70
updateFunction · 0.70
detectChangesFunction · 0.70
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…