Skip to content

Commit

Permalink
update: replacing the constructor service declarations with injection
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeyyeKurtulus committed Mar 25, 2024
1 parent aff3231 commit 780cf42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 3 additions & 2 deletions npm/ng-packs/apps/dev-app/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { AuthService } from '@abp/ng.core';
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent {
private authService = inject(AuthService);

loading = false;
get hasLoggedIn(): boolean {
return this.authService.isAuthenticated;
}

constructor(private authService: AuthService) {}
login() {
this.loading = true;
this.authService.navigateToLogin();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthService, ConfigStateService } from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared';
import { Component, Injector, OnInit } from '@angular/core';
import { Component, Injector, OnInit, inject } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { throwError } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators';
Expand All @@ -14,6 +14,12 @@ const { maxLength, required } = Validators;
templateUrl: './login.component.html',
})
export class LoginComponent implements OnInit {
protected injector = inject(Injector);
protected fb = inject(UntypedFormBuilder);
protected toasterService = inject(ToasterService);
protected authService = inject(AuthService);
protected configState = inject(ConfigStateService);

form!: UntypedFormGroup;

inProgress?: boolean;
Expand All @@ -22,14 +28,6 @@ export class LoginComponent implements OnInit {

authWrapperKey = eAccountComponents.AuthWrapper;

constructor(
protected injector: Injector,
protected fb: UntypedFormBuilder,
protected toasterService: ToasterService,
protected authService: AuthService,
protected configState: ConfigStateService,
) {}

ngOnInit() {
this.init();
this.buildForm();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import {eLayoutType, SubscriptionService} from '@abp/ng.core';
import { eLayoutType, SubscriptionService } from '@abp/ng.core';
import { collapseWithMargin, slideFromBottom } from '@abp/ng.theme.shared';
import {AfterViewInit, Component} from '@angular/core';
import { AfterViewInit, Component, inject } from '@angular/core';
import { LayoutService } from '../../services/layout.service';


@Component({
selector: 'abp-layout-application',
templateUrl: './application-layout.component.html',
animations: [slideFromBottom, collapseWithMargin],
providers: [LayoutService, SubscriptionService],
})
export class ApplicationLayoutComponent implements AfterViewInit {
public service = inject(LayoutService);
// required for dynamic component
static type = eLayoutType.application;

constructor(public service: LayoutService) {}

ngAfterViewInit() {
this.service.subscribeWindowSize();
}
Expand Down

0 comments on commit 780cf42

Please sign in to comment.