angular - ionic 2 custom directives not working in android 5 -
i have custom directive below limit number of characters in input field in ionic 2 app. see below. unfortunately works in android 4.2.2 not on android 5.1.1. can help?
import { directive, input, hostlistener } '@angular/core'; /* generated class limitto directive. see https://angular.io/docs/ts/latest/api/core/index/directivemetadata-class.html more info on angular 2 directives. */ @directive({ selector: '[limit-to]' // attribute selector }) export class limitto { @input('limit-to') limitto; constructor() { } //hostlistener decorator handle event handlers input (onkeypress) @hostlistener('keypress', ['$event']) onkeypress(ev) { const limit = +this.limitto; //convert number // once reaches limit set, stop propgating event. if (ev.target.value.length === limit) { ev.preventdefault(); } } }
thank you, ashley
Comments
Post a Comment