Skip to content

Commit e9ed976

Browse files
committed
refactor(app): ng generate @angular/core:inject migration
1 parent 9d1f157 commit e9ed976

155 files changed

Lines changed: 573 additions & 541 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/app.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { Component, HostListener, Inject, OnInit, DOCUMENT } from '@angular/core';
2+
import { Component, HostListener, OnInit, DOCUMENT, inject } from '@angular/core';
33
import { RouterOutlet } from '@angular/router';
44

55
@Component({
@@ -9,14 +9,14 @@ import { RouterOutlet } from '@angular/router';
99
imports: [RouterOutlet]
1010
})
1111
export class AppComponent implements OnInit {
12+
private document = inject<Document>(DOCUMENT);
13+
1214
public title = 'Samples';
1315
private theme = 'default-theme';
1416
private styleElem: HTMLStyleElement;
1517
private typefacesLoaded = ['Titillium Web', 'Roboto'];
1618
private typefaceUrl = 'https://fonts.googleapis.com/css?family=';
1719

18-
constructor(@Inject(DOCUMENT) private document: Document) {}
19-
2020
public ngOnInit() {
2121
this.createThemeStyle();
2222
}

src/app/data-display/badge/badge-icon/badge-icon.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, inject } from '@angular/core';
22
import { heartMonitor } from '@igniteui/material-icons-extended';
33
import { IgxIconService, IgxAvatarComponent, IgxBadgeComponent } from 'igniteui-angular';
44

@@ -8,8 +8,9 @@ import { IgxIconService, IgxAvatarComponent, IgxBadgeComponent } from 'igniteui-
88
templateUrl: './badge-icon.component.html',
99
imports: [IgxAvatarComponent, IgxBadgeComponent]
1010
})
11-
export class BadgeIconComponent implements OnInit {
12-
constructor (protected _iconService: IgxIconService) {}
11+
export class BadgeIconComponent implements OnInit {
12+
protected _iconService = inject(IgxIconService);
13+
1314

1415
public ngOnInit() {
1516
this._iconService.addSvgIconFromText(heartMonitor.name, heartMonitor.value, 'imx-icons');

src/app/data-display/chip/chip-area-sample/chip-area-sample.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectorRef, Component } from '@angular/core';
1+
import { ChangeDetectorRef, Component, inject } from '@angular/core';
22
import { IBaseChipEventArgs, IChipsAreaReorderEventArgs, IgxChipsAreaComponent, IgxChipComponent, IgxAvatarComponent, IgxPrefixDirective, IgxIconComponent } from 'igniteui-angular';
33

44

@@ -10,6 +10,8 @@ import { IBaseChipEventArgs, IChipsAreaReorderEventArgs, IgxChipsAreaComponent,
1010
})
1111

1212
export class ChipAreaSampleComponent {
13+
changeDetectionRef = inject(ChangeDetectorRef);
14+
1315
public chipList = [
1416
{
1517
id: '770-504-2217',
@@ -28,9 +30,6 @@ export class ChipAreaSampleComponent {
2830
}
2931
];
3032

31-
32-
constructor(public changeDetectionRef: ChangeDetectorRef) { }
33-
3433
public chipRemoved(event: IBaseChipEventArgs) {
3534
this.chipList = this.chipList.filter((item) => item.id !== event.owner.id);
3635
this.changeDetectionRef.detectChanges();

src/app/data-display/chip/chip-simple/chip-simple.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectorRef, Component } from '@angular/core';
1+
import { ChangeDetectorRef, Component, inject } from '@angular/core';
22
import { IBaseChipEventArgs, IgxChipComponent, IgxIconComponent, IgxPrefixDirective } from 'igniteui-angular';
33

44

@@ -10,6 +10,8 @@ import { IBaseChipEventArgs, IgxChipComponent, IgxIconComponent, IgxPrefixDirect
1010
})
1111

1212
export class ChipSimpleComponent {
13+
changeDetectionRef = inject(ChangeDetectorRef);
14+
1315
public chipList = [
1416
{
1517
text: 'Country',
@@ -33,8 +35,6 @@ export class ChipSimpleComponent {
3335
}
3436
];
3537

36-
constructor(public changeDetectionRef: ChangeDetectorRef) { }
37-
3838

3939
public chipRemoved(event: IBaseChipEventArgs) {
4040
this.chipList = this.chipList.filter((item) => item.id !== event.owner.id);

src/app/data-display/chip/chip-styling/chip-styling.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectorRef, Component } from '@angular/core';
1+
import { ChangeDetectorRef, Component, inject } from '@angular/core';
22
import { IBaseChipEventArgs, IChipsAreaReorderEventArgs, IgxChipsAreaComponent, IgxChipComponent, IgxIconComponent, IgxPrefixDirective } from 'igniteui-angular';
33

44

@@ -10,6 +10,8 @@ import { IBaseChipEventArgs, IChipsAreaReorderEventArgs, IgxChipsAreaComponent,
1010
})
1111

1212
export class ChipStylingSampleComponent {
13+
changeDetectionRef = inject(ChangeDetectorRef);
14+
1315
public chipList = [
1416
{
1517
text: 'Country',
@@ -33,8 +35,6 @@ export class ChipStylingSampleComponent {
3335
}
3436
];
3537

36-
constructor(public changeDetectionRef: ChangeDetectorRef) { }
37-
3838

3939
public chipRemoved(event: IBaseChipEventArgs) {
4040
this.chipList = this.chipList.filter((item) => item.id !== event.owner.id);

src/app/data-display/icon/icon-service-sample/icon-service-sample.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '@angular/core';
1+
import { Component, inject } from '@angular/core';
22
import { IgxIconService, IgxCardComponent, IgxCardHeaderComponent, IgxAvatarComponent, IgxIconComponent, IgxCardHeaderTitleDirective, IgxCardHeaderSubtitleDirective, IgxCardActionsComponent, IgxButtonDirective, IgxSuffixDirective } from 'igniteui-angular';
33

44
@Component({
@@ -8,6 +8,8 @@ import { IgxIconService, IgxCardComponent, IgxCardHeaderComponent, IgxAvatarComp
88
imports: [IgxCardComponent, IgxCardHeaderComponent, IgxAvatarComponent, IgxIconComponent, IgxCardHeaderTitleDirective, IgxCardHeaderSubtitleDirective, IgxCardActionsComponent, IgxButtonDirective, IgxSuffixDirective]
99
})
1010
export class IconServiceSampleComponent {
11+
private iconService = inject(IgxIconService);
12+
1113
private weather = [{
1214
icon: 'partly_cloudy',
1315
description: '18° Partly Cloudy'
@@ -25,7 +27,7 @@ export class IconServiceSampleComponent {
2527
return this.weather.at(0).description
2628
};
2729

28-
constructor(private iconService: IgxIconService) {
30+
constructor() {
2931
// Add the SVG assets to the icon service collection
3032
this.iconService.addSvgIcon('partly_cloudy', 'assets/images/icons/partly_cloudy.svg', 'weather');
3133
this.iconService.addSvgIcon('sunny', 'assets/images/icons/sunny.svg', 'weather');

src/app/data-display/icon/material-icons-extended/material-icons-extended.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/member-ordering */
2-
import { Component, Inject, OnInit, Pipe, PipeTransform, Renderer2, forwardRef, DOCUMENT } from '@angular/core';
2+
import { Component, OnInit, Pipe, PipeTransform, Renderer2, forwardRef, DOCUMENT, inject } from '@angular/core';
33
import * as fileSaver from 'file-saver';
44

55
import { IgxIconService, ISelectionEventArgs, IgxSelectComponent, IgxLabelDirective, IgxSelectItemComponent, IgxInputGroupComponent, IgxInputDirective, IgxPrefixDirective, IgxIconComponent, IgxSuffixDirective, IgxButtonDirective } from 'igniteui-angular';
@@ -22,11 +22,10 @@ interface ICategoryOption {
2222
imports: [IgxSelectComponent, IgxLabelDirective, IgxSelectItemComponent, IgxInputGroupComponent, IgxInputDirective, IgxPrefixDirective, IgxIconComponent, IgxSuffixDirective, IgxButtonDirective, forwardRef(() => CategoriesFilterPipe), forwardRef(() => FilterByName)]
2323
})
2424
export class MaterialIconsExtendedComponent implements OnInit {
25-
constructor(
26-
private iconService: IgxIconService,
27-
@Inject(DOCUMENT) private document: Document,
28-
private renderer: Renderer2
29-
) { }
25+
private iconService = inject(IgxIconService);
26+
private document = inject<Document>(DOCUMENT);
27+
private renderer = inject(Renderer2);
28+
3029

3130
public categories: ICategoryOption[] = [
3231
{

src/app/data-display/icon/material-symbols/material-symbols.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, inject } from '@angular/core';
22
import { IgxIconService, IgxIconComponent } from 'igniteui-angular';
33

44
@Component({
@@ -8,7 +8,8 @@ import { IgxIconService, IgxIconComponent } from 'igniteui-angular';
88
imports: [IgxIconComponent]
99
})
1010
export class MaterialSymbolsComponent implements OnInit {
11-
constructor(private iconService: IgxIconService) { }
11+
private iconService = inject(IgxIconService);
12+
1213

1314
public ngOnInit() {
1415
this.iconService.registerFamilyAlias('material-symbols', 'material-symbols-outlined');

src/app/data-display/icon/svg-icon-sample/svg-icon-sample.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, inject } from '@angular/core';
22
import { IgxIconService, IgxIconComponent } from 'igniteui-angular';
33

44
@Component({
@@ -8,8 +8,8 @@ import { IgxIconService, IgxIconComponent } from 'igniteui-angular';
88
imports: [IgxIconComponent]
99
})
1010
export class SvgIconSampleComponent implements OnInit {
11+
private iconService = inject(IgxIconService);
1112

12-
constructor(private iconService: IgxIconService) { }
1313

1414
public ngOnInit() {
1515
// register custom SVG icons

src/app/data-display/text-highlight/text-highlight-sample-1/text-highlight-sample-1.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-len */
2-
import { Component, OnDestroy, ViewChild } from '@angular/core';
2+
import { Component, OnDestroy, ViewChild, inject } from '@angular/core';
33
import { IgxTextHighlightDirective, IgxTextHighlightService, IgxInputGroupComponent, IgxPrefixDirective, IgxIconComponent, IgxInputDirective, IgxSuffixDirective, IgxIconButtonDirective, IgxRippleDirective } from 'igniteui-angular';
44

55
import { FormsModule } from '@angular/forms';
@@ -11,6 +11,8 @@ import { FormsModule } from '@angular/forms';
1111
imports: [IgxInputGroupComponent, IgxPrefixDirective, IgxIconComponent, FormsModule, IgxInputDirective, IgxSuffixDirective, IgxIconButtonDirective, IgxRippleDirective, IgxTextHighlightDirective]
1212
})
1313
export class TextHighlightSample1Component implements OnDestroy {
14+
private highlightService = inject(IgxTextHighlightService);
15+
1416
@ViewChild(IgxTextHighlightDirective, { read: IgxTextHighlightDirective, static: true })
1517
public highlight: IgxTextHighlightDirective;
1618
// tslint:disable max-line-length
@@ -29,8 +31,6 @@ export class TextHighlightSample1Component implements OnDestroy {
2931
public caseSensitive = false;
3032
public index = 0;
3133

32-
constructor(private highlightService: IgxTextHighlightService) { }
33-
3434
public ngOnDestroy() {
3535
this.highlightService.destroyGroup('group1');
3636
}

0 commit comments

Comments
 (0)