Khiem Nguyen Khiem Nguyen - 1 year ago 148
TypeScript Question

How can I disable keyup loopback in angular 2?

I have a form like below:

<div *ngIf="formLabel" style="padding: 0 16px">
<md-input [(ngModel)]="label.Name" placeholder="Label name" style="width: 100%">
<md-list-item *ngFor="let label of labels">
<h3 md-line>
<md-icon class="fa fa-tag" fontSet="fa" fontIcon="fa-tag" (click)="openFormLabel(label)"></md-icon>
<a routerLink="/label/{{label.Id}}">{{label.Name}}</a>

How can I disable {{labe.Name}} auto bind text when I'm typing in md-ipnut ?

Answer Source

For that, use one way binding like,


Update :

If you intended to update label.Name value after completion of typing, you can use blur event as shown here along with one-way binding

<form #f='ngForm' (ngSubmit)="onSubmit(f.form)">

          <input (blur)="changeValue(f.form)"   //<<<===here
                 type="text" #Name="ngModel"      
                 name="Name" >

export class AppComponent {




Demo :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download