thomas wilbrink
thomas wilbrink

Reputation: 23

ionic 3 html button linked to a funtion in .ts but says its undefined

I have this line of code which I have at the end of a sign-up type form:

<button ion-button full color="secondary" onclick="save()"></button>`

However when I click on it I get an error saying save is undefined but I have this in my .ts file

save() {
  this.submitAttempt= true;
  console.log("success!");
  console.log(this.slideOneForm.value);
  console.log(this.slideTwoForm.value);
  console.log(this.slideThreeForm.value);
}

Is my mistake in the definition or in the button itself and how can I fix this?

Upvotes: 2

Views: 96

Answers (2)

Sonicd300
Sonicd300

Reputation: 2049

Your error is in the button's html, you bind it like (click)="save()" not onclick="save()"

Upvotes: 2

Sampath
Sampath

Reputation: 65870

This is an issue of the Ionic live reloader (debug server). So you have 2 options here.

Option 1: Change something on .ts file and allow to server reload again

Option 2: Kill the server and restart it again using ionic serve

Upvotes: 0

Related Questions