title: Angular 2 directives & modules
body: <p>In older version of Angular 2 I could import directives like 
  <code>import {CounterDirective} from './counter.directive';</code></p>
  
  <p>and use it.</p>
  
  <p>Since the new App Module, I couldn't find any documentation about how make my own module and import it to my app. For example, I created a directive using Angular-CLI: <code>ng g directive counter</code> to create a counter to a given number. That's my directive code:</p>
  
  <pre><code>import { Directive,Output,Input,EventEmitter } from '@angular/core';
  
  @Directive({
    selector: '[counter]'
  })
  export class CounterDirective {
  
    constructor() { }
  
    @Output() countoChange = new EventEmitter();
      private _timer;
      private _duration: number;
      private _countTo: number;
      private _countFrom: number;
      private _step: number;
  
      @Input()
      set duration(duration) {
          this._duration = parseFloat(duration);
          this.run();
      }
  
      @Input()
      set countTo(countTo) {
          this._countTo = parseFloat(countTo);
          this.run();
      }
  
      @Input()
      set countFrom(countFrom) {
          this._countFrom = parseFloat(countFrom);
          this.run();
      }
  
      @Input()
      set step(step) {
          this._step = parseFloat(step);
          this.run();
      }
  
      run() {
          var _this = this;
          clearInterval(_this._timer);
  
          if (isNaN(_this._duration)) {
              return false;
          }
  
          if (isNaN(_this._step)) {
              return false;
          }
  
          if (isNaN(_this._countFrom)) {
              return false;
          }
  
          if (isNaN(_this._countTo)) {
              return false;
          }
  
          if (_this._step &lt;= 0) {
              console.info('Step must be greater than 0.');
              return false;
          }
  
          if (_this._duration &lt;= 0) {
              console.info('Duration must be greater than 0.');
              return false;
          }
  
          if (_this._step &gt; _this._duration*1000) {
              console.info('Step must be equal or smaller than duration.');
              return false;
          }
  
          var intermediate  = _this._countFrom;
          var increment     = Math.abs(_this._countTo - _this._countFrom) / ((_this._duration * 1000) / _this._step);
  
          _this.countoChange.emit(intermediate);
  
          _this._timer = setInterval(function() {
              if (_this._countTo &lt; _this._countFrom) {
                  if (intermediate &lt;= _this._countTo) {
                      clearInterval(_this._timer);
                      _this.countoChange.emit(_this._countTo);
                  } else {
                      _this.countoChange.emit(intermediate);
                      intermediate -= increment;
                  }
              } else {
                  if (intermediate &gt;= _this._countTo) {
                      clearInterval(_this._timer);
                      _this.countoChange.emit(_this._countTo);
                  } else {
                      _this.countoChange.emit(intermediate);
                      intermediate += increment;
                  }
              }
          }, _this._step);
      }
  
  }
  </code></pre>
  
  <p>How I can import it with my AppModule and use it?</p>