title: Angular 2 : Directives and providers in @component decorator
body: <p>Hi i am new to Angular 2, i referred many other similar post but nothing helped me.</p>
  
  <p>Below are my Queries</p>
  
  <ol>
  <li><p>When to use Directives and providers parameters in @component decorator? Do i need to pass component inside any of this parameters while i import component</p></li>
  <li><p>I made a http subscribe call inside oninit() but it never's gets called when page loads I get undefined value in console. how do i call it when a page loads.</p></li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ngOnInit() {
      this.loginService.getLoginData()
        .subscribe(data =&gt; {
          this.loginData = data;
          this.loginDataLength = data.length;
        });
        console.log(this.loginData);
    }</code></pre>
  </div>
  </div>
  </p>
  
  <ol start="3">
  <li>how do i communicate between 2 components while routing?</li>
  <li>What is  the difference between Directive and Component</li>
  </ol>