Mohan Arumugam

Mohan Arumugam

  • NA
  • 465
  • 37.4k

Angular text box value

May 4 2018 3:44 AM
HOME.COMPONENT.HTML
 
<div class="AddItem">
   <input #inputBox1 placeholder="Add Item" class="addtext">
   <button (click) = "pushItem(inputBox1.value)">ADD</button>
</div>
 
<ul>
      <li *ngFor="let i of items>
         {{i}}
         <span>x</span>
      </li>
</ul>
 
 HOME.COMPONENT.TS
 
 export class HomeComponent implements OnInit {
       items = ["angular","react","HTML"]
 
       pushItem = function(value){
             this.items.push(value);
}
 
I am new to Angular 
 
After button clicked values are be listed correctly. 
but 
I need textbox be empty again.

Answers (3)