title: How to save text from input to variable in angular?
body: <p>I'm trying to take text from one of my component.html files and save the input to a variable in a method in one of my .ts files. Can you help?</p>
  
  <h2>home.component.html file:</h2>
  
  <pre><code>Username: &lt;input ng-model="username"&gt;&lt;br&gt;
  Password: &lt;input ng-model="pass"&gt;  
  &lt;button (click)="login()"&gt;Login&lt;/button&gt;
  </code></pre>
  
  <h2>home.component.ts file:</h2>
  
  <pre><code>export class HomeComponent implements OnInit {
  
      login()
      {
       const usr= {{username}};
       const password={{pass}};
       print("user is"+usr " Password is"+password);
  
      }
  
  }
  </code></pre>