Browse Source

Refactor to use Angular's new output() function

Replaces EventEmitter and @Output() with the new output() function in chart, tree, and test components. This modernizes the codebase to align with recent Angular best practices and reduces boilerplate.
pull/24766/head
Fahri Gedik 9 months ago
parent
commit
a29326402b
  1. 10
      npm/ng-packs/packages/components/chart.js/src/chart.component.ts
  2. 13
      npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts
  3. 8
      npm/ng-packs/packages/core/src/lib/tests/replaceable-template.directive.spec.ts

10
npm/ng-packs/packages/components/chart.js/src/chart.component.ts

@ -4,14 +4,13 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnDestroy,
Output,
SimpleChanges,
ViewChild,
inject
inject,
output,
} from '@angular/core';
let Chart: any;
@ -53,9 +52,8 @@ export class ChartComponent implements AfterViewInit, OnDestroy, OnChanges {
@Input() responsive = true;
@Output() dataSelect = new EventEmitter();
@Output() initialized = new EventEmitter<boolean>();
readonly dataSelect = output<any>();
readonly initialized = output<boolean>();
@ViewChild('canvas') canvas!: ElementRef<HTMLCanvasElement>;

13
npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts

@ -3,11 +3,10 @@ import {
ChangeDetectorRef,
Component,
ContentChild,
EventEmitter,
inject,
Input,
OnInit,
Output,
output,
TemplateRef,
ViewEncapsulation,
} from '@angular/core';
@ -63,11 +62,11 @@ export class TreeComponent implements OnInit {
@ContentChild('menu') menu: TemplateRef<any>;
@ContentChild(TreeNodeTemplateDirective) customNodeTemplate: TreeNodeTemplateDirective;
@ContentChild(ExpandedIconTemplateDirective) expandedIconTemplate: ExpandedIconTemplateDirective;
@Output() readonly checkedKeysChange = new EventEmitter();
@Output() readonly expandedKeysChange = new EventEmitter<string[]>();
@Output() readonly selectedNodeChange = new EventEmitter();
@Output() readonly dropOver = new EventEmitter<DropEvent>();
@Output() readonly nzExpandChange = new EventEmitter<NzFormatEmitEvent>();
readonly checkedKeysChange = output<any>();
readonly expandedKeysChange = output<string[]>();
readonly selectedNodeChange = output<any>();
readonly dropOver = output<DropEvent>();
readonly nzExpandChange = output<NzFormatEmitEvent>();
@Input() noAnimation = true;
@Input() draggable: boolean;
@Input() checkable: boolean;

8
npm/ng-packs/packages/core/src/lib/tests/replaceable-template.directive.spec.ts

@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
import { Component, Input, inject, output } from '@angular/core';
import { Router } from '@angular/router';
import { createDirectiveFactory, SpectatorDirective } from '@ngneat/spectator/vitest';
import { BehaviorSubject } from 'rxjs';
@ -18,11 +18,9 @@ class DefaultComponent {
@Input()
twoWay: boolean;
@Output()
readonly twoWayChange = new EventEmitter<boolean>();
readonly twoWayChange = output<boolean>();
@Output()
readonly someOutput = new EventEmitter<string>();
readonly someOutput = output<string>();
setTwoWay(value) {
this.twoWay = value;

Loading…
Cancel
Save