BACKGROUND: I have a dashboard for my app with 3 ion-items, I want them to be clickable so as someone clicks/taps on the item it will navigate to a different page.
Here is a screenshot to give a better understanding: https://imgur.com/TCv3pMc
Here is a link to my github repo with all the files: https://github.com/jamesslater/boutiquesolicitors
PROBLEM: To do this I've been trying to call a method which routes to the correct page. However, while testing with a console.log I have noticed both (click) and href do not work at all.
Can someone please explain how I can get this working? Any help is greatly appreciated!
RELEVANT CODE:
dashboard.page.html
<div class="nav-wrapper" style="background: white;">
<ion-header class="navbar">
<ion-buttons slot="end">
<ion-button (click)="logout()">
<ion-icon slot="icon-only" color="white" name="log-out"></ion-icon>
</ion-button>
</ion-buttons>
<ion-img src="assets/logo.png"></ion-img>
</ion-header>
</div>
<ion-content padding text-center>
<div class="profile">
<ion-avatar>
<img src="assets/user.png">
</ion-avatar>
<h1>Hello Richard,</h1>
<ion-label>How can we help you today?</ion-label>
</div>
<ion-item (click)="search()">
<ion-icon name="search" slot="start"></ion-icon>
<ion-label>Search for a service</ion-label>
</ion-item>
<ion-item>
<ion-icon name="paper" slot="start"></ion-icon>
<ion-label>View our latest news</ion-label>
</ion-item>
<ion-item>
<ion-icon name="card" slot="start"></ion-icon>
<ion-label>Pay a bill</ion-label>
</ion-item>
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button tab="about">
<ion-icon name="information-circle-outline"></ion-icon>
<ion-label>About Us</ion-label>
</ion-tab-button>
<ion-tab-button href="members/dashboard">
<ion-icon color="blue" name="home"></ion-icon>
<ion-label>Dashboard</ion-label>
</ion-tab-button>
<ion-tab-button tab="contact">
<ion-icon name="contacts"></ion-icon>
<ion-label>Contact Us</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-content>
dashboard.page.ts
import { AuthenticationService } from './../../services/authentication.service';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.page.html',
styleUrls: ['./dashboard.page.scss'],
})
export class DashboardPage implements OnInit {
error = this.error;
constructor(private authService: AuthenticationService, private router: Router) { }
ngOnInit() {
}
logout() {
this.router.navigate(['login']);
// this.authService.logout();
}
search() {
console.log('clicked');
this.router.navigate(['members/services']);
}
}