Skip to content

Commit 7ec7359

Browse files
committed
chore(text-highlight): update with service
1 parent 3d94439 commit 7ec7359

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-len */
22
import { Component, ViewChild } from '@angular/core';
3-
import { IgxTextHighlightDirective } from 'igniteui-angular';
3+
import { IgxTextHighlightDirective, IgxTextHighlightService } from 'igniteui-angular';
44

55
@Component({
66
selector: 'app-text-highlight-1',
@@ -26,6 +26,8 @@ export class TextHighlightSample1Component {
2626
public caseSensitive = false;
2727
public index = 0;
2828

29+
constructor(private highlightService: IgxTextHighlightService) { }
30+
2931
public searchKeyDown(ev) {
3032
if (this.searchText) {
3133
if (ev.key === 'Enter' || ev.key === 'ArrowDown' || ev.key === 'ArrowRight') {
@@ -74,7 +76,7 @@ export class TextHighlightSample1Component {
7476
this.index = this.index > this.matchCount - 1 ? 0 : this.index;
7577

7678
if (this.matchCount) {
77-
IgxTextHighlightDirective.setActiveHighlight('group1', {
79+
this.highlightService.setActiveHighlight('group1', {
7880
index: this.index
7981
});
8082
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-len */
22
import { Component, ViewChildren } from '@angular/core';
3-
import { IgxTextHighlightDirective } from 'igniteui-angular';
3+
import { IgxTextHighlightDirective, IgxTextHighlightService } from 'igniteui-angular';
44

55
@Component({
66
selector: 'app-text-highlight-2',
@@ -32,6 +32,8 @@ export class TextHighlightSample2Component {
3232
public caseSensitive = false;
3333
public index = 0;
3434

35+
constructor(private highlightService: IgxTextHighlightService) { }
36+
3537
public searchKeyDown(ev) {
3638
if (this.searchText) {
3739
if (ev.key === 'Enter' || ev.key === 'ArrowDown' || ev.key === 'ArrowRight') {
@@ -98,7 +100,7 @@ export class TextHighlightSample2Component {
98100

99101
const actualIndex = row === 0 ? this.index : this.index - matchesArray[row - 1];
100102

101-
IgxTextHighlightDirective.setActiveHighlight('group1', { index: actualIndex, row });
103+
this.highlightService.setActiveHighlight('group1', { index: actualIndex, row });
102104
}
103105
} else {
104106
this.highlights.forEach((h) => {

src/app/data-display/text-highlight/text-highlight-style/text-highlight-style.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-len */
22
import { Component, ViewChild } from '@angular/core';
3-
import { IgxTextHighlightDirective } from 'igniteui-angular';
3+
import { IgxTextHighlightDirective, IgxTextHighlightService } from 'igniteui-angular';
44

55
@Component({
66
selector: 'app-text-highlight-style',
@@ -25,6 +25,8 @@ export class TextHighlightStyleComponent {
2525
public caseSensitive = false;
2626
public index = 0;
2727

28+
constructor(private highlightService: IgxTextHighlightService) { }
29+
2830
public searchKeyDown(ev) {
2931
if (this.searchText) {
3032
if (ev.key === 'Enter' || ev.key === 'ArrowDown' || ev.key === 'ArrowRight') {
@@ -73,7 +75,7 @@ export class TextHighlightStyleComponent {
7375
this.index = this.index > this.matchCount - 1 ? 0 : this.index;
7476

7577
if (this.matchCount) {
76-
IgxTextHighlightDirective.setActiveHighlight('group1', {
78+
this.highlightService.setActiveHighlight('group1', {
7779
index: this.index
7880
});
7981
}

0 commit comments

Comments
 (0)