title: Typescript - Bind ngModel to property of object
body: <p>I have an object called <code>user</code>:</p>
  
  <pre><code>let user = {};
  </code></pre>
  
  <p>How can I bind an input to a undefined property? E.g.</p>
  
  <pre><code>&lt;input [(ngModel)]="user.name" placeholder="Enter your name"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>And whenever the user enters his name, I want the <code>ngModel</code> to create the undefined property of that object and result in this:</p>
  
  <pre><code>user = {name: "John"};
  </code></pre>
  
  <p>Is this also possible to be done at deepter levels? E.g.</p>
  
  <pre><code>&lt;input [(ngModel)]="user.homeaddress.postcode" placeholder="Enter your post code"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>to result in:</p>
  
  <pre><code>user = {name: "John", homeaddress: {postcode: "E20 1QS"}};
  </code></pre>