Skip to content

Commit e3fe906

Browse files
committed
feat(api): add standalone support to components and directives
Now it is not required to use `NgModules` with this library
1 parent 268e464 commit e3fe906

18 files changed

+70
-75
lines changed

goldens/ng-dynamic-component/api.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ElementRef } from '@angular/core';
1212
import { EnvironmentInjector } from '@angular/core';
1313
import { EventEmitter } from '@angular/core';
1414
import * as i0 from '@angular/core';
15-
import * as i3 from '@angular/common';
1615
import { InjectionToken } from '@angular/core';
1716
import { Injector } from '@angular/core';
1817
import { IterableDiffers } from '@angular/core';
@@ -43,7 +42,7 @@ export class ComponentOutletInjectorDirective implements DynamicComponentInjecto
4342
// (undocumented)
4443
get componentRef(): ComponentRef<unknown>;
4544
// (undocumented)
46-
static ɵdir: i0.ɵɵDirectiveDeclaration<ComponentOutletInjectorDirective, "[ngComponentOutlet]", ["ndcComponentOutletInjector"], {}, {}, never, never, false>;
45+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComponentOutletInjectorDirective, "[ngComponentOutlet]", ["ndcComponentOutletInjector"], {}, {}, never, never, true>;
4746
// (undocumented)
4847
static ɵfac: i0.ɵɵFactoryDeclaration<ComponentOutletInjectorDirective, [{ host: true; }]>;
4948
}
@@ -58,7 +57,7 @@ export class ComponentOutletInjectorModule {
5857
// Warning: (ae-forgotten-export) The symbol "i2" needs to be exported by the entry point public-api.d.ts
5958
//
6059
// (undocumented)
61-
static ɵmod: i0.ɵɵNgModuleDeclaration<ComponentOutletInjectorModule, [typeof i1.ComponentOutletInjectorDirective, typeof i2.ComponentOutletIoDirective], [typeof i3.CommonModule], [typeof i1.ComponentOutletInjectorDirective, typeof i2.ComponentOutletIoDirective]>;
60+
static ɵmod: i0.ɵɵNgModuleDeclaration<ComponentOutletInjectorModule, never, [typeof i1.ComponentOutletInjectorDirective, typeof i2.ComponentOutletIoDirective], [typeof i1.ComponentOutletInjectorDirective, typeof i2.ComponentOutletIoDirective]>;
6261
}
6362

6463
// @public (undocumented)
@@ -71,7 +70,7 @@ export class ComponentOutletIoDirective implements DoCheck {
7170
// (undocumented)
7271
ngDoCheck(): void;
7372
// (undocumented)
74-
static ɵdir: i0.ɵɵDirectiveDeclaration<ComponentOutletIoDirective, "[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]", ["ndcDynamicIo"], { "ngComponentOutletNdcDynamicInputs": "ngComponentOutletNdcDynamicInputs"; "ngComponentOutletNdcDynamicOutputs": "ngComponentOutletNdcDynamicOutputs"; }, {}, never, never, false>;
73+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComponentOutletIoDirective, "[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]", ["ndcDynamicIo"], { "ngComponentOutletNdcDynamicInputs": "ngComponentOutletNdcDynamicInputs"; "ngComponentOutletNdcDynamicOutputs": "ngComponentOutletNdcDynamicOutputs"; }, {}, never, never, true>;
7574
// (undocumented)
7675
static ɵfac: i0.ɵɵFactoryDeclaration<ComponentOutletIoDirective, never>;
7776
}
@@ -113,7 +112,7 @@ export class DynamicAttributesDirective implements DoCheck {
113112
// (undocumented)
114113
setAttribute(name: string, value: string, namespace?: string): void;
115114
// (undocumented)
116-
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicAttributesDirective, "[ndcDynamicAttributes],[ngComponentOutletNdcDynamicAttributes]", ["ndcDynamicAttributes"], { "ndcDynamicAttributes": "ndcDynamicAttributes"; "ngComponentOutletNdcDynamicAttributes": "ngComponentOutletNdcDynamicAttributes"; }, {}, never, never, false>;
115+
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicAttributesDirective, "[ndcDynamicAttributes],[ngComponentOutletNdcDynamicAttributes]", ["ndcDynamicAttributes"], { "ndcDynamicAttributes": "ndcDynamicAttributes"; "ngComponentOutletNdcDynamicAttributes": "ngComponentOutletNdcDynamicAttributes"; }, {}, never, never, true>;
117116
// (undocumented)
118117
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicAttributesDirective, [null, null, { optional: true; }]>;
119118
}
@@ -125,10 +124,10 @@ export class DynamicAttributesModule {
125124
// (undocumented)
126125
static ɵinj: i0.ɵɵInjectorDeclaration<DynamicAttributesModule>;
127126
// Warning: (ae-forgotten-export) The symbol "i1_4" needs to be exported by the entry point public-api.d.ts
128-
// Warning: (ae-forgotten-export) The symbol "i3_3" needs to be exported by the entry point public-api.d.ts
127+
// Warning: (ae-forgotten-export) The symbol "i2_2" needs to be exported by the entry point public-api.d.ts
129128
//
130129
// (undocumented)
131-
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicAttributesModule, [typeof i1_4.DynamicAttributesDirective], [typeof i3.CommonModule], [typeof i1_4.DynamicAttributesDirective, typeof i3_3.ComponentOutletInjectorModule]>;
130+
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicAttributesModule, never, [typeof i1_4.DynamicAttributesDirective], [typeof i1_4.DynamicAttributesDirective, typeof i2_2.ComponentOutletInjectorModule]>;
132131
}
133132

134133
// @public (undocumented)
@@ -155,7 +154,7 @@ export class DynamicComponent<C = unknown> implements OnChanges, DynamicComponen
155154
// (undocumented)
156155
ngOnChanges(changes: SimpleChanges): void;
157156
// (undocumented)
158-
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicComponent<any>, "ndc-dynamic", never, { "ndcDynamicComponent": "ndcDynamicComponent"; "ndcDynamicInjector": "ndcDynamicInjector"; "ndcDynamicProviders": "ndcDynamicProviders"; "ndcDynamicContent": "ndcDynamicContent"; "ndcDynamicNgModuleRef": "ndcDynamicNgModuleRef"; "ndcDynamicEnvironmentInjector": "ndcDynamicEnvironmentInjector"; }, { "ndcDynamicCreated": "ndcDynamicCreated"; }, never, never, false>;
157+
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicComponent<any>, "ndc-dynamic", never, { "ndcDynamicComponent": "ndcDynamicComponent"; "ndcDynamicInjector": "ndcDynamicInjector"; "ndcDynamicProviders": "ndcDynamicProviders"; "ndcDynamicContent": "ndcDynamicContent"; "ndcDynamicNgModuleRef": "ndcDynamicNgModuleRef"; "ndcDynamicEnvironmentInjector": "ndcDynamicEnvironmentInjector"; }, { "ndcDynamicCreated": "ndcDynamicCreated"; }, never, never, true>;
159158
// (undocumented)
160159
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicComponent<any>, never>;
161160
}
@@ -196,7 +195,7 @@ export class DynamicDirectivesDirective implements OnDestroy, DoCheck {
196195
// (undocumented)
197196
ngOnDestroy(): void;
198197
// (undocumented)
199-
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicDirectivesDirective, "[ndcDynamicDirectives],[ngComponentOutletNdcDynamicDirectives]", never, { "ndcDynamicDirectives": "ndcDynamicDirectives"; "ngComponentOutletNdcDynamicDirectives": "ngComponentOutletNdcDynamicDirectives"; }, { "ndcDynamicDirectivesCreated": "ndcDynamicDirectivesCreated"; }, never, never, false>;
198+
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicDirectivesDirective, "[ndcDynamicDirectives],[ngComponentOutletNdcDynamicDirectives]", never, { "ndcDynamicDirectives": "ndcDynamicDirectives"; "ngComponentOutletNdcDynamicDirectives": "ngComponentOutletNdcDynamicDirectives"; }, { "ndcDynamicDirectivesCreated": "ndcDynamicDirectivesCreated"; }, never, never, true>;
200199
// (undocumented)
201200
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicDirectivesDirective, [null, null, null, null, { optional: true; }]>;
202201
}
@@ -210,7 +209,7 @@ export class DynamicDirectivesModule {
210209
// Warning: (ae-forgotten-export) The symbol "i1_5" needs to be exported by the entry point public-api.d.ts
211210
//
212211
// (undocumented)
213-
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicDirectivesModule, [typeof i1_5.DynamicDirectivesDirective], [typeof i3.CommonModule], [typeof i1_5.DynamicDirectivesDirective, typeof i3_3.ComponentOutletInjectorModule]>;
212+
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicDirectivesModule, never, [typeof i1_5.DynamicDirectivesDirective], [typeof i1_5.DynamicDirectivesDirective, typeof i2_2.ComponentOutletInjectorModule]>;
214213
}
215214

216215
// @public (undocumented)
@@ -223,7 +222,7 @@ export class DynamicIoDirective implements DoCheck {
223222
// (undocumented)
224223
ngDoCheck(): void;
225224
// (undocumented)
226-
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicIoDirective, "[ndcDynamicInputs],[ndcDynamicOutputs]", ["ndcDynamicIo"], { "ndcDynamicInputs": "ndcDynamicInputs"; "ndcDynamicOutputs": "ndcDynamicOutputs"; }, {}, never, never, false>;
225+
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicIoDirective, "[ndcDynamicInputs],[ndcDynamicOutputs]", ["ndcDynamicIo"], { "ndcDynamicInputs": "ndcDynamicInputs"; "ndcDynamicOutputs": "ndcDynamicOutputs"; }, {}, never, never, true>;
227226
// (undocumented)
228227
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicIoDirective, never>;
229228
}
@@ -237,7 +236,7 @@ export class DynamicIoModule {
237236
// Warning: (ae-forgotten-export) The symbol "i1_3" needs to be exported by the entry point public-api.d.ts
238237
//
239238
// (undocumented)
240-
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicIoModule, [typeof i1_3.DynamicIoDirective], [typeof i3.CommonModule], [typeof i1_3.DynamicIoDirective, typeof i3_3.ComponentOutletInjectorModule]>;
239+
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicIoModule, never, [typeof i1_3.DynamicIoDirective], [typeof i1_3.DynamicIoDirective, typeof i2_2.ComponentOutletInjectorModule]>;
241240
}
242241

243242
// @public (undocumented)
@@ -247,10 +246,10 @@ export class DynamicModule {
247246
// (undocumented)
248247
static ɵinj: i0.ɵɵInjectorDeclaration<DynamicModule>;
249248
// Warning: (ae-forgotten-export) The symbol "i1_2" needs to be exported by the entry point public-api.d.ts
250-
// Warning: (ae-forgotten-export) The symbol "i3_2" needs to be exported by the entry point public-api.d.ts
249+
// Warning: (ae-forgotten-export) The symbol "i2_3" needs to be exported by the entry point public-api.d.ts
251250
//
252251
// (undocumented)
253-
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicModule, [typeof i1_2.DynamicComponent], [typeof i3.CommonModule, typeof i3_2.DynamicIoModule], [typeof i1_2.DynamicComponent, typeof i3_2.DynamicIoModule]>;
252+
static ɵmod: i0.ɵɵNgModuleDeclaration<DynamicModule, never, [typeof i1_2.DynamicIoModule, typeof i2_3.DynamicComponent], [typeof i1_2.DynamicIoModule, typeof i2_3.DynamicComponent]>;
254253
}
255254

256255
// @public @deprecated (undocumented)

projects/ng-dynamic-component/src/lib/component-outlet/component-outlet-injector.directive.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ComponentOutletInjectorDirective } from './component-outlet-injector.di
55

66
describe('ComponentOutletInjectorDirective', () => {
77
@Component({ selector: 'dynamic', template: '' })
8-
class DynamicComponent {}
8+
class Dynamic1Component {}
99

1010
@Component({
1111
selector: 'host',
@@ -18,9 +18,10 @@ describe('ComponentOutletInjectorDirective', () => {
1818
}
1919

2020
const testSetup = new TestSetup(HostComponent, {
21-
props: { component: DynamicComponent },
21+
props: { component: Dynamic1Component },
2222
ngModule: {
23-
declarations: [ComponentOutletInjectorDirective, DynamicComponent],
23+
imports: [ComponentOutletInjectorDirective],
24+
declarations: [Dynamic1Component],
2425
},
2526
});
2627

@@ -45,6 +46,6 @@ describe('ComponentOutletInjectorDirective', () => {
4546

4647
const directive = fixture.getHost().directive;
4748

48-
expect(directive?.componentRef.instance).toBeInstanceOf(DynamicComponent);
49+
expect(directive?.componentRef.instance).toBeInstanceOf(Dynamic1Component);
4950
});
5051
});

projects/ng-dynamic-component/src/lib/component-outlet/component-outlet-injector.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
// eslint-disable-next-line @angular-eslint/directive-selector
1414
selector: '[ngComponentOutlet]',
1515
exportAs: 'ndcComponentOutletInjector',
16+
standalone: true,
1617
providers: [
1718
{
1819
provide: DynamicComponentInjectorToken,
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { CommonModule } from '@angular/common';
21
import { NgModule } from '@angular/core';
32

43
import { ComponentOutletInjectorDirective } from './component-outlet-injector.directive';
@@ -8,8 +7,7 @@ import { ComponentOutletIoDirective } from './component-outlet-io.directive';
87
* @public
98
*/
109
@NgModule({
11-
imports: [CommonModule],
10+
imports: [ComponentOutletInjectorDirective, ComponentOutletIoDirective],
1211
exports: [ComponentOutletInjectorDirective, ComponentOutletIoDirective],
13-
declarations: [ComponentOutletInjectorDirective, ComponentOutletIoDirective],
1412
})
1513
export class ComponentOutletInjectorModule {}

projects/ng-dynamic-component/src/lib/component-outlet/component-outlet-io.directive.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ComponentOutletIoDirective } from './component-outlet-io.directive';
66

77
describe('Directive: ComponentOutletIo', () => {
88
@Component({ selector: 'dynamic', template: 'DynamicComponent' })
9-
class DynamicComponent {
9+
class Dynamic1Component {
1010
@Input() prop1: any;
1111
@Input() prop2: any;
1212
@Output() output = new EventEmitter<any>();
@@ -21,13 +21,10 @@ describe('Directive: ComponentOutletIo', () => {
2121
}
2222

2323
const testSetup = new TestSetup(HostComponent, {
24-
props: { component: DynamicComponent },
24+
props: { component: Dynamic1Component },
2525
ngModule: {
26-
declarations: [
27-
ComponentOutletIoDirective,
28-
ComponentOutletInjectorDirective,
29-
DynamicComponent,
30-
],
26+
imports: [ComponentOutletIoDirective, ComponentOutletInjectorDirective],
27+
declarations: [Dynamic1Component],
3128
},
3229
});
3330

@@ -40,7 +37,7 @@ describe('Directive: ComponentOutletIo', () => {
4037
template: `<ng-container *ngComponentOutlet="component; ndcDynamicInputs: inputs"></ng-container>`,
4138
});
4239

43-
expect(fixture.getComponent(DynamicComponent)).toEqual(
40+
expect(fixture.getComponent(Dynamic1Component)).toEqual(
4441
expect.objectContaining({
4542
prop1: '123',
4643
prop2: 1,
@@ -60,7 +57,7 @@ describe('Directive: ComponentOutletIo', () => {
6057

6158
expect(outputs.output).not.toHaveBeenCalled();
6259

63-
fixture.getComponent(DynamicComponent)!.output.emit('data');
60+
fixture.getComponent(Dynamic1Component)!.output.emit('data');
6461

6562
expect(outputs.output).toHaveBeenCalledWith('data');
6663
});

projects/ng-dynamic-component/src/lib/component-outlet/component-outlet-io.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { InputsType, IoService, OutputsType } from '../io';
1010
// eslint-disable-next-line @angular-eslint/directive-selector
1111
'[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]',
1212
exportAs: 'ndcDynamicIo',
13+
standalone: true,
1314
providers: [IoService],
1415
})
1516
export class ComponentOutletIoDirective implements DoCheck {

projects/ng-dynamic-component/src/lib/dynamic-attributes/dynamic-attributes.directive.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import { Component, Type } from '@angular/core';
33
import { TestFixture, TestSetup } from '../../test';
44
import { ComponentOutletInjectorDirective } from '../component-outlet';
5-
import { DynamicComponent as NdcDynamicComponent } from '../dynamic.component';
5+
import { DynamicComponent } from '../dynamic.component';
66
import {
77
AttributesMap,
88
DynamicAttributesDirective,
99
} from './dynamic-attributes.directive';
1010

1111
describe('DynamicAttributesDirective', () => {
1212
@Component({ selector: 'dynamic', template: `` })
13-
class DynamicComponent {}
13+
class Dynamic1Component {}
1414

1515
@Component({
1616
selector: 'host',
@@ -28,17 +28,15 @@ describe('DynamicAttributesDirective', () => {
2828

2929
class DynamicTestFixture<THost> extends TestFixture<THost> {
3030
getDynamicElem() {
31-
return this.getComponentElement(DynamicComponent)!;
31+
return this.getComponentElement(Dynamic1Component)!;
3232
}
3333
}
3434

3535
const testSetup = new TestSetup(HostComponent, {
36-
props: { component: DynamicComponent },
36+
props: { component: Dynamic1Component },
3737
ngModule: {
38-
declarations: [
39-
DynamicAttributesDirective,
40-
ComponentOutletInjectorDirective,
41-
],
38+
imports: [DynamicAttributesDirective, ComponentOutletInjectorDirective],
39+
declarations: [Dynamic1Component],
4240
},
4341
fixtureCtor: DynamicTestFixture,
4442
});
@@ -252,7 +250,7 @@ describe('DynamicAttributesDirective', () => {
252250
[ndcDynamicAttributes]="attrs"
253251
></ndc-dynamic>
254252
`,
255-
ngModule: { declarations: [NdcDynamicComponent] },
253+
ngModule: { imports: [DynamicComponent] },
256254
});
257255

258256
expect(fixture.getDynamicElem().attributes).toMatchObject({

projects/ng-dynamic-component/src/lib/dynamic-attributes/dynamic-attributes.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface AttributeActions {
3333
@Directive({
3434
selector: '[ndcDynamicAttributes],[ngComponentOutletNdcDynamicAttributes]',
3535
exportAs: 'ndcDynamicAttributes',
36+
standalone: true,
3637
})
3738
export class DynamicAttributesDirective implements DoCheck {
3839
@Input()
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { CommonModule } from '@angular/common';
21
import { NgModule } from '@angular/core';
32

43
import { ComponentOutletInjectorModule } from '../component-outlet';
@@ -8,8 +7,7 @@ import { DynamicAttributesDirective } from './dynamic-attributes.directive';
87
* @public
98
*/
109
@NgModule({
11-
imports: [CommonModule],
10+
imports: [DynamicAttributesDirective],
1211
exports: [DynamicAttributesDirective, ComponentOutletInjectorModule],
13-
declarations: [DynamicAttributesDirective],
1412
})
1513
export class DynamicAttributesModule {}

projects/ng-dynamic-component/src/lib/dynamic-directives/dynamic-directives.directive.spec.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323

2424
import { TestFixture, TestSetup } from '../../test';
2525
import { ComponentOutletInjectorDirective } from '../component-outlet';
26-
import { DynamicComponent as NdcDynamicComponent } from '../dynamic.component';
26+
import { DynamicComponent } from '../dynamic.component';
2727
import { IoFactoryService } from '../io';
2828
import {
2929
DirectiveRef,
@@ -34,7 +34,7 @@ import {
3434

3535
describe('Directive: DynamicDirectives', () => {
3636
@Component({ selector: 'dynamic', template: `` })
37-
class DynamicComponent {}
37+
class Dynamic1Component {}
3838

3939
@Component({
4040
selector: 'host',
@@ -121,14 +121,10 @@ describe('Directive: DynamicDirectives', () => {
121121
}
122122

123123
const testSetup = new TestSetup(HostComponent, {
124-
props: { component: DynamicComponent },
124+
props: { component: Dynamic1Component },
125125
ngModule: {
126-
declarations: [
127-
DynamicDirectivesDirective,
128-
ComponentOutletInjectorDirective,
129-
HostComponent,
130-
DynamicComponent,
131-
],
126+
imports: [DynamicDirectivesDirective, ComponentOutletInjectorDirective],
127+
declarations: [Dynamic1Component],
132128
providers: [IoFactoryService],
133129
},
134130
fixtureCtor: DirectivesTestFixture,
@@ -643,7 +639,7 @@ describe('Directive: DynamicDirectives', () => {
643639
ngModule: { imports: [CommonModule] },
644640
});
645641

646-
const dynamicElem = fixture.getComponentElement(DynamicComponent)!;
642+
const dynamicElem = fixture.getComponentElement(Dynamic1Component)!;
647643

648644
expect(dynamicElem).toBeTruthy();
649645
expect(dynamicElem.classes).toEqual({ cls1: true, cls2: true });
@@ -664,7 +660,7 @@ describe('Directive: DynamicDirectives', () => {
664660
ngModule: { imports: [CommonModule] },
665661
});
666662

667-
const dynamicElem = fixture.getComponentElement(DynamicComponent)!;
663+
const dynamicElem = fixture.getComponentElement(Dynamic1Component)!;
668664

669665
expect(dynamicElem).toBeTruthy();
670666
expect(dynamicElem.classes).toEqual({ cls1: true, cls2: true });
@@ -684,12 +680,11 @@ describe('Directive: DynamicDirectives', () => {
684680
></ndc-dynamic>
685681
`,
686682
ngModule: {
687-
imports: [CommonModule],
688-
declarations: [NdcDynamicComponent],
683+
imports: [CommonModule, DynamicComponent],
689684
},
690685
});
691686

692-
const dynamicElem = fixture.getComponentElement(DynamicComponent)!;
687+
const dynamicElem = fixture.getComponentElement(Dynamic1Component)!;
693688

694689
expect(dynamicElem).toBeTruthy();
695690
expect(dynamicElem.classes).toEqual({ cls1: true, cls2: true });

projects/ng-dynamic-component/src/lib/dynamic-directives/dynamic-directives.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface DirectiveRef<T> {
7070
*/
7171
@Directive({
7272
selector: '[ndcDynamicDirectives],[ngComponentOutletNdcDynamicDirectives]',
73+
standalone: true,
7374
providers: [IoFactoryService],
7475
})
7576
export class DynamicDirectivesDirective implements OnDestroy, DoCheck {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { CommonModule } from '@angular/common';
21
import { NgModule } from '@angular/core';
32

43
import { ComponentOutletInjectorModule } from '../component-outlet';
@@ -8,8 +7,7 @@ import { DynamicDirectivesDirective } from './dynamic-directives.directive';
87
* @public
98
*/
109
@NgModule({
11-
imports: [CommonModule],
10+
imports: [DynamicDirectivesDirective],
1211
exports: [DynamicDirectivesDirective, ComponentOutletInjectorModule],
13-
declarations: [DynamicDirectivesDirective],
1412
})
1513
export class DynamicDirectivesModule {}

0 commit comments

Comments
 (0)