title: Angular 2/4 : How to check length of input's value using directive?
body: <p>I've created one custom attribute directive that can validate input, It has value or not. Please refer below code. </p>
  
  <p>I don't know why if condition is not working, in console.log it is showing 0 only. is there anything wrong in my code?</p>
  
  <p>I tried with other angular's app lifecycle event too.</p>
  
  <p>Thanks!</p>
  
  <pre><code>import { Directive, ElementRef, Input, AfterContentInit ,Renderer } from '@angular/core';
  
  @Directive({ selector: '[inputfocus]' })
  
  export class InputFocusedDirective implements AfterContentInit {
      public valLength;
  
      constructor(public el: ElementRef, public renderer: Renderer) {}
  
      ngAfterContentInit() {
  
          var valLength = this.el.nativeElement.value.length;
      consol.log("valLength "+ valLength );
  
          if (valLength &gt; 0) {
             this.renderer.setElementClass(this.el.nativeElement.parentElement, 'focused', true);
          }
  
  
      }
  }
  </code></pre>