title: Angular2 - Pass router param as variable to ngForm
body: <p>Just having a bit of difficulty passing a router param (id) to an ngForm and then to an event emitter. Here is how I get the id - as you can see the first console.log works fine, i can get the id from the router. Now I am trying to assign this to my singleOpenHome object (but get an undefined error):</p>
  
  <pre><code>@Input() singleOpenHome: OpenHomeModel;
  
  ngOnInit() {
          // Get the slug on it from the router
          this.route.params.forEach((params: Params) =&gt; {
              let id = params['propertyID'];
              console.log('id on the child is:'+id);
              //this.singleOpenHome.propertyID == id; Cannot read property 'propertyID' of undefined
          });
      }
  </code></pre>
  
  <p>Now i am wanting to pass this to a form:</p>
  
  <pre><code> &lt;form class="my2" #form="ngForm" (ngSubmit)="handleSubmit(form.value, form.valid)" novalidate&gt;&lt;/form&gt;
  </code></pre>
  
  <p>Here is my event emmitter:</p>
  
  <pre><code>@Output()
      update: EventEmitter&lt;OpenHomeModel&gt; = new EventEmitter&lt;OpenHomeModel&gt;();
  
      constructor(private route: ActivatedRoute) {}
  
      handleSubmit(sinlgeOpenHome: OpenHomeModel, isValid: boolean) {
          if (isValid) {
              this.update.emit(sinlgeOpenHome);
          }
      }
  </code></pre>
  
  <p>Any help appreciated</p>