title: Angular subject not updating form
body: <p>I've been following a course on LinkedIn Learning but clicking on a list and having the values populate a form are not working for me. I'm new to Angular (and development) so apologies if this is silly, or I don't describe it correctly.</p>
  
  <p>I have 2 components and an API service file pulling the data from an ASP.Net Core API:</p>
  
  <ol>
  <li>List-codes</li>
  <li>Add-code</li>
  <li>Api</li>
  </ol>
  
  <p><strong>list-codes.component.html</strong></p>
  
  <pre><code>&lt;div class="card-body"&gt;
      &lt;p class="card-text"&gt;select a code from the list below.&lt;/p&gt;
      &lt;ul class="list-group" *ngFor="let code of codes"&gt;
          &lt;a href="#" class="list-group-item list-group-item-action" (click)="api.selectCode(code)"&gt;{{code.codeName}}&lt;/a&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>list-codes.component.ts</strong></p>
  
  <pre><code>ngOnInit() {
      this.api.getCodes().subscribe(res =&gt; {
          this.codes = res
      })
  }
  </code></pre>
  
  <p><strong>add-code.component.html</strong></p>
  
  <pre><code>&lt;form&gt;
      &lt;div class="input-group"&gt;
          &lt;div class="input-group-prepend"&gt;
          &lt;span class="input-group-text" id=""&gt;:)&lt;/span&gt;
          &lt;/div&gt;
          &lt;input type="text" class="form-control" [(ngModel)]="code.codename" name="codename" placeholder="code name"&gt;
          &lt;input type="text" class="form-control" [(ngModel)]="code.description" name="description" placeholder="description"&gt;
      &lt;/div&gt;
      &lt;button (click)="post(code)" class="btn btn-primary"&gt;Submit&lt;/button&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p><strong>add-code.component.ts</strong></p>
  
  <pre><code>export class AddCodeComponent {
      code = {}
      constructor(private api: ApiService) {}
      ngOnit() {
          this.api.codeSelected.subscribe(code =&gt; this.code = code)
      }
      post(code) {
          this.api.postCode(code)  
      }
  }
  </code></pre>
  
  <p><strong>api.service.ts</strong></p>
  
  <pre><code>export class ApiService {
  
      private selectedCode = new Subject&lt;any&gt;(); // holds reference to clicked item in list
      codeSelected= this.selectedCode.asObservable(); // subscribe
  
      constructor(private http: HttpClient) {}
      getCodes() {
          return this.http.get('http://localhost:58561/api/codes');
      }
      postCode(code) {
          this.http.post('http://localhost:58561/api/codes', code).subscribe(res =&gt; {
              console.log(res)
          })
      }
      selectCode(code) {
          this.selectedCode.next(code)
      }
  }
  </code></pre>
  
  <p>Listing the codes works fine. </p>
  
  <p>The issue just seems to be clicking and having the code in the list populate the values in the add-code form (it works in the video tutorial) but it doesn't work for me. I'm assuming I've missed something obvious?</p>
  
  <p>I did a bit of reading and everyone seems to handle Subject Observables slightly different and I"m obviously just missing the point!</p>
  
  <p>For brevity, I've provided the snippets I think are relevant. If I've overlooked something important to include please let me know.</p>
  
  <p>Any help welcomed!</p>
  
  <p>Cheers,
  Adam</p>