typescript - Directive selector doesn't find element -
when change selector 'input' works on every input can find. if change 'input[numeric]' nothing happens (yes input[numeric] there). doing wrong? isn't supposed work this? says css selector in documentation...
import {directive, elementref} '@angular/core'; import {ngmodel} '@angular/common';  @directive({     selector: 'input[numeric]',     host: {         '(input)' : 'oninputchange()'     } }) export class numberformatdirective {      constructor(public model: ngmodel, public element: elementref) {         console.log(1);     }      oninputchange(): {         console.log(2);     } } the template looks this:
<input *ngif='!ismultiline()'        [attr.readonly]='readonly'        [attr.disabled]='isinputdisabled()'        [attr.minlength]='minlength'        [attr.maxlength]='maxlength'        [attr.numeric]='isnumeric()'        [(ngmodel)]='value' (ngmodelchange)='valuechanged($event)'        (keyup.enter)='updatevaluerestore()'        (keyup.escape)='resetvalue()'        (focus)='onfocus()'        (blur)='onblur()'        autocomplete='off'/> 
check
plnkr.co/edit/vfrqjipiffjqydnsim49?p=preview
its working expected.
Comments
Post a Comment