Need help on custom directives for android platforms

Dear All,

I have built a custom directive that limit the numbers of characters in an input field. This directive works on android 4.2.2 but not on android 5.1.1.

Can someone please advise?


Can someone help please?


Below is my code

import { Directive, Input, HostListener } from ‘@angular/core’;

Generated class for the LimitTo directive.

for more info on Angular 2 Directives.
selector: ‘[limit-to]’ // Attribute selector
export class LimitTo {

@Input(‘limit-to’) limitTo;

constructor() {

//HostListener decorator handle event handlers for input (onKeyPress)
@HostListener(‘keypress’, [’$event’])
onkeypress(ev) {
const limit = +this.limitTo; //convert to number
// once it reaches the limit set, stop propgating event.
if ( === limit) {


Hello Everyone,

Badly need some hint.