title: Create child components in the parent component in Angular
body: <p>I'm pretty new to Angular &amp; Typescript. Familiar with OOP &amp; Javascript. And im bit confused as to how to do the following:</p>
  
  <p>I want to create and insert a number of <code>child</code> component instances inside the <code>parent</code> component depending on a variable in the <code>parent</code> component. I also want to give each <code>child</code> component values that I pass it from the <code>parent</code>. Code below gives me:
  <code>Uncaught Error: Can't resolve all parameters for ParentComponent: (?, ?).</code>
  Which is confusing as hell to me since im passing the correct amount of parameters &amp; correct types?</p>
  
  <p>Parnet Component:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { ChildComponent } from './child/child.component';
  
  @Component({
    selector: 'parent',
    template: `
        &lt;ul&gt;
        &lt;li *ngFor='let child of collOfChildren'&gt;
            &lt;child&gt;&lt;/child&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    `
  })
  export class ParentComponent implements OnInit {
    private collOfChildren: Array&lt;ChildComponent&gt; = [];
  
    numOfChildren = 3;
    childNames = ['Child 1', 'Child 2','Child 3'];
  
    constructor() { 
    }
  
    ngOnInit() {
      for(let i = 0; i &lt; this.numOfChildren; i++) {
        this.collOfChildren.push(new ChildComponent(this.childNames[i],5));
      }
    }
  
  }
  </code></pre>
  
  <p>Child Component:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  @Component({
    selector: 'child',
    templateUrl: './child.component.html',
    styleUrls: ['./child.component.css']
  })
  export class ChildComponent implements OnInit {
    private name:String;
    private age:number;
  
    constructor(name:String, age:number) { 
      this.name = name;
      this.age = age;
    }
  
    ngOnInit() {
    }
  
  }
  </code></pre>