Mr world wide
Mr world wide

Reputation: 4814

How can i use click in angular 4

<input type ="text" name="something" id="something"required (click)="saveData()>

I have input field like this if the required error is not there then only click mouse event should work(call).!

how can I do that.? i am new to angular

I want something like this:

 <input type ="text" name="something" id="something"required *ngIf="something.errors == null (click)="saveData() " >

Upvotes: 0

Views: 488

Answers (1)

Vivek Doshi
Vivek Doshi

Reputation: 58543

You can do this like :

(click)="something.errors == null ? saveData() : false"

WORKING DEMO


OR as @PankajParkar's comment

(click)="something.errors?.length && saveData()"

Upvotes: 1

Related Questions