title: Angular 2: redirecting through component.ts
body: <p>I am trying to tell my component to redirect to a page in the ngOnInit() function but it doesnt work. My code looks something like this: </p>
  
  <pre><code>constructor(private router: Router) {}
  
  ngOnInit() {
    this.initForm();
  }
  
  initForm(){
    this.router.navigateByUrl('ng/loan/loan');
  }
  </code></pre>
  
  <p>The code above will not make the component redirect me to my desired path, but if i add a button in my template file and give it <code>(click)="initForm()"</code> it does. What am i missing here?</p>