I am trying to build an app with a simple click function. I added the handler to the buttons in the users.html page, and the app runs until I arrive at the page where I can click on either of the two handled buttons. When I click on the buttons, I get the error noted below, that it is not a function.
I defined the function onLoadUser() in the users.ts file. The class is exported.
Technology
- Ionic 3
- Angular2
Error
Directory structure
users.html
<ion-header>
<ion-navbar>
<ion-title>The Users</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button ion-button (click)="onLoadUser('Max')">User 'Max'</button>
<hr>
<button ion-button (click)="onLoadUser('Anna')">User 'Anna'</button>
</ion-content>
<ion-footer padding>
<p>The Footer</p>
</ion-footer>
users.ts
import { Component } from '@angular/core';
import { NavController } from "ionic-angular";
import { UserPage } from "./user/user";
@Component({
selector: 'page-users',
templateUrl: 'users.html'
})
export class UsersPage {
constructor (private navCtrl: NavController) {}
onLoadUser(name: string) {
this.navCtrl.push(UserPage, {userName: name});
}
}
How can I connect the onLoadUser function to the button click event?

