Skip to content

Commit 82b2ba4

Browse files
authored
[Angular] Migrate to signals (sort.directive.ts) (#28209)
1 parent c0d8d31 commit 82b2ba4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class SortByDirective {
4040
effect(() => {
4141
if (this.iconComponent()) {
4242
let icon: IconDefinition = this.sortIcon;
43-
const { predicate, order } = this.sort.sortState();
43+
const { predicate, order } = this.sort.sortState()();
4444
if (predicate === this.<%= jhiPrefix %>SortBy() && order !== undefined) {
4545
icon = order === 'asc' ? this.sortAscIcon : this.sortDescIcon;
4646
}

generators/angular/templates/src/main/webapp/app/shared/sort/sort.directive.ts.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
See the License for the specific language governing permissions and
1717
limitations under the License.
1818
-%>
19-
import { Directive, EventEmitter, Input, Output } from '@angular/core';
19+
import { Directive, input, output, OutputEmitterRef } from '@angular/core';
2020
import { SortOrder, SortState, SortStateSignal } from './sort-state';
2121

2222
export interface SortChangeDirective<T> {
23-
sortChange: EventEmitter<SortState>;
23+
sortChange: OutputEmitterRef<SortState>;
2424

2525
sort(field: T): void;
2626
}
@@ -29,12 +29,12 @@ export interface SortChangeDirective<T> {
2929
selector: '[<%= jhiPrefix %>Sort]',
3030
})
3131
export class SortDirective implements SortChangeDirective<string> {
32-
@Input() sortState!: SortStateSignal;
32+
readonly sortState = input.required<SortStateSignal>();
3333

34-
@Output() sortChange = new EventEmitter<SortState>();
34+
readonly sortChange = output<SortState>();
3535

3636
sort(field: string): void {
37-
const { predicate, order } = this.sortState();
37+
const { predicate, order } = this.sortState()();
3838
const toggle = (): SortOrder => (order === 'asc' ? 'desc' : 'asc');
3939
this.sortChange.emit({ predicate: field, order: field !== predicate ? 'asc' : toggle() });
4040
}

0 commit comments

Comments
 (0)