Thursday, 9 February 2017

NG2-Filter text to convert upper case character, even entering as lower case

NG2-Filter text to convert upper case character, even entering as lower case.
======================================================

template.html
================

<input  type="text" [ngModel]="sectionSearch" (ngModelChange)="onSearchSection($event)" 
#input (input)="input.value=$event.target.value.toUpperCase()" placeholder="Search...">
 
componets.ts
============
onSearchSection(event:Event) {

    this.allsection = this.toFilterAllSection.filter(
              section => section.displayName.toUpperCase().indexOf(event) >= 0
              );

    } 

Note:
data.section is backend data as an array.

No comments:

Post a Comment

KISS, DRY, SOLID, YAGNI — A Simple Guide to Some Principles of Software Engineering and Clean Code

1 — KISS (Keep It Simple, Stupid)  Simplicity triumphs over complexity. Direct and clear codes are better for developing, maintaining, and s...