mercredi 25 avril 2018

Implement text valditation on li item in Angular 2

I am trying to implement input that is in li component text validation. Basicly when user types the text, it is send to beckend and checked (returns if input is valid). If its valid, user can post it.

<li *ngFor="let value of values" [ngClass]="{'danger': !isValid}">
  <input [value]="value.title" (keyup)="onTitleChange($event)"/>
  <button [ngClass]="{'disabled': !isValid}">Post</button>
</li>

What I want to do is check input value and based on it put classes and li and button components. Every input value is independant from other li components.

I tiried to accomplish this by using forms but it wasn't the solution I was looking for or maby was implementing it wrong way. Do you have any suggestions?




Aucun commentaire:

Enregistrer un commentaire