title: How to reload the current Angular 2 Component
body: <p>How can I reload the same component again in Angular 2?</p>
  
  <p>Here is my code below:</p>
  
  <pre><code>import { Component, OnInit, ElementRef, Renderer } from '@angular/core';
  import { Router, ActivatedRoute, Params } from '@angular/router';
  import { productModel } from '../_models/index';
  import { categoryListService } from '../_services/index';
  
  @Component({
    selector: 'app-product',
    templateUrl: 'product.component.html',
    styleUrls: ['product.component.css']
  })
  export class productComponent implements OnInit {
    uidproduct: productModel;
    param: number;
    constructor(
      private elementRef: ElementRef,
      private route: ActivatedRoute,
      private router: Router,
      private categoryListService: categoryListService) { }
  
    ngOnInit() {
      this.route.params.subscribe(product =&gt; {
        console.log('logging sub product obj', product);
      });
      this.uidproduct = JSON.parse(sessionStorage.getItem('product'));
      var s = document.createElement("script");
      s.type = "text/javascript";
      s.src = "http://this/external/script/needs/to/be/loaded/each/time.js";
      this.elementRef.nativeElement.appendChild(s);
    }
    nextproduct(){ 
      let i = this.uidproduct.order;
      this.categoryListService.findNextproduct(this.uidproduct);
      this.param = ++i;
      this.router.navigate([`/product/${this.param}`]);
    }
  }
  </code></pre>
  
  <p><code>nextproduct()</code> is bound to a click event in the template.</p>
  
  <p>The <code>uidproduct</code> is a JSON object that has a number of properties and i'm updating the DOM with <code>{{uidproduct.classname}}</code></p>
  
  <p>I'm using this in the template like this: </p>
  
  <pre><code>&lt;div id="selected-product" class="{{uidproduct.classname}}"&gt;
  </code></pre>
  
  <p>When I click the <code>&lt;button (click)="nextproduct()"&gt;</code> it will change the class property in the DOM but I need to reload the component for the external script to have effect.</p>