Skip to content

Commit b0e31b1

Browse files
committed
feat: element-ref directive
1 parent a3ee02a commit b0e31b1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ElementRefDirective } from './element-ref.directive';
2+
import { ElementRef } from '@angular/core';
3+
import { TestBed } from '@angular/core/testing';
4+
5+
class MockElementRef extends ElementRef {}
6+
7+
describe('ElementRefDirective', () => {
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({
10+
providers: [{ provide: ElementRef, useClass: MockElementRef }],
11+
});
12+
});
13+
it('should create an instance', () => {
14+
TestBed.runInInjectionContext(() => {
15+
const directive = new ElementRefDirective();
16+
expect(directive).toBeTruthy();
17+
});
18+
});
19+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Directive, ElementRef, inject } from '@angular/core';
2+
3+
@Directive({
4+
selector: '[cElementRef]',
5+
exportAs: 'cElementRef',
6+
standalone: true,
7+
})
8+
export class ElementRefDirective {
9+
public readonly elementRef = inject(ElementRef);
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { SharedModule } from './shared.module';
1+
export { ElementRefDirective } from './element-ref.directive';
22
export { HtmlAttributesDirective } from './html-attr.directive';
33
export { TemplateIdDirective } from './template-id.directive';
44
export { ThemeDirective } from './theme.directive';
5+
export { SharedModule } from './shared.module';

0 commit comments

Comments
 (0)