Browse Source

update: replacing the constructor service declarations with injection

pull/19413/head
sumeyyeKurtulus 3 years ago
parent
commit
780cf42ff4
  1. 5
      npm/ng-packs/apps/dev-app/src/app/home/home.component.ts
  2. 16
      npm/ng-packs/packages/account/src/lib/components/login/login.component.ts
  3. 8
      npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts

5
npm/ng-packs/apps/dev-app/src/app/home/home.component.ts

@ -1,17 +1,18 @@
import { AuthService } from '@abp/ng.core'; import { AuthService } from '@abp/ng.core';
import { Component } from '@angular/core'; import { Component, inject } from '@angular/core';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.component.html', templateUrl: './home.component.html',
}) })
export class HomeComponent { export class HomeComponent {
private authService = inject(AuthService);
loading = false; loading = false;
get hasLoggedIn(): boolean { get hasLoggedIn(): boolean {
return this.authService.isAuthenticated; return this.authService.isAuthenticated;
} }
constructor(private authService: AuthService) {}
login() { login() {
this.loading = true; this.loading = true;
this.authService.navigateToLogin(); this.authService.navigateToLogin();

16
npm/ng-packs/packages/account/src/lib/components/login/login.component.ts

@ -1,6 +1,6 @@
import { AuthService, ConfigStateService } from '@abp/ng.core'; import { AuthService, ConfigStateService } from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared'; 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 { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { throwError } from 'rxjs'; import { throwError } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators'; import { catchError, finalize } from 'rxjs/operators';
@ -14,6 +14,12 @@ const { maxLength, required } = Validators;
templateUrl: './login.component.html', templateUrl: './login.component.html',
}) })
export class LoginComponent implements OnInit { 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; form!: UntypedFormGroup;
inProgress?: boolean; inProgress?: boolean;
@ -22,14 +28,6 @@ export class LoginComponent implements OnInit {
authWrapperKey = eAccountComponents.AuthWrapper; authWrapperKey = eAccountComponents.AuthWrapper;
constructor(
protected injector: Injector,
protected fb: UntypedFormBuilder,
protected toasterService: ToasterService,
protected authService: AuthService,
protected configState: ConfigStateService,
) {}
ngOnInit() { ngOnInit() {
this.init(); this.init();
this.buildForm(); this.buildForm();

8
npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts

@ -1,9 +1,8 @@
import {eLayoutType, SubscriptionService} from '@abp/ng.core'; import { eLayoutType, SubscriptionService } from '@abp/ng.core';
import { collapseWithMargin, slideFromBottom } from '@abp/ng.theme.shared'; 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'; import { LayoutService } from '../../services/layout.service';
@Component({ @Component({
selector: 'abp-layout-application', selector: 'abp-layout-application',
templateUrl: './application-layout.component.html', templateUrl: './application-layout.component.html',
@ -11,11 +10,10 @@ import { LayoutService } from '../../services/layout.service';
providers: [LayoutService, SubscriptionService], providers: [LayoutService, SubscriptionService],
}) })
export class ApplicationLayoutComponent implements AfterViewInit { export class ApplicationLayoutComponent implements AfterViewInit {
public service = inject(LayoutService);
// required for dynamic component // required for dynamic component
static type = eLayoutType.application; static type = eLayoutType.application;
constructor(public service: LayoutService) {}
ngAfterViewInit() { ngAfterViewInit() {
this.service.subscribeWindowSize(); this.service.subscribeWindowSize();
} }

Loading…
Cancel
Save