Skip to content

Commit 664d8e3

Browse files
committed
refactor: converts constructor-based injection to the inject function
1 parent 4741173 commit 664d8e3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

projects/code-editor/code-editor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ViewEncapsulation,
1313
booleanAttribute,
1414
forwardRef,
15+
inject,
1516
} from '@angular/core';
1617
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
1718

@@ -61,6 +62,8 @@ export const External = Annotation.define<boolean>();
6162
],
6263
})
6364
export class CodeEditor implements OnChanges, OnInit, OnDestroy, ControlValueAccessor {
65+
private _elementRef = inject<ElementRef<Element>>(ElementRef);
66+
6467
/**
6568
* EditorView's [root](https://codemirror.net/docs/ref/#view.EditorView.root).
6669
*
@@ -138,8 +141,6 @@ export class CodeEditor implements OnChanges, OnInit, OnDestroy, ControlValueAcc
138141
private _onChange: (value: string) => void = () => {};
139142
private _onTouched: () => void = () => {};
140143

141-
constructor(private _elementRef: ElementRef<Element>) {}
142-
143144
/**
144145
* The instance of [EditorView](https://codemirror.net/docs/ref/#view.EditorView).
145146
*/

projects/code-editor/diff-editor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ViewEncapsulation,
1313
booleanAttribute,
1414
forwardRef,
15+
inject,
1516
} from '@angular/core';
1617
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
1718

@@ -64,6 +65,8 @@ export interface DiffEditorModel {
6465
],
6566
})
6667
export class DiffEditor implements OnChanges, OnInit, OnDestroy, ControlValueAccessor {
68+
private _elementRef = inject<ElementRef<Element>>(ElementRef);
69+
6770
/**
6871
* The editor's built-in setup. The value can be set to
6972
* [`basic`](https://codemirror.net/docs/ref/#codemirror.basicSetup),
@@ -148,8 +151,6 @@ export class DiffEditor implements OnChanges, OnInit, OnDestroy, ControlValueAcc
148151
private _onChange: (value: DiffEditorModel) => void = () => {};
149152
private _onTouched: () => void = () => {};
150153

151-
constructor(private _elementRef: ElementRef<Element>) {}
152-
153154
/** The merge view instance. */
154155
mergeView?: MergeView;
155156

0 commit comments

Comments
 (0)