I'm very new to ionic and have this simple question which to my surprise i cannot find my answer anywhere i search.
what i want is to implement simple page navigation just like this : https://ionicframework.com/docs/api/nav
the source code below the mobile gives javascript codes yet i want in angular/ionic code.
any other documentations use sophisticated codes and for some reason i cannot understand it.
how could i archive this goal with the most simplest code possible for IONIC-5/Angular(using 'ion-nav')?
HTML:
this is what i have gone so far:
<ion-nav root="rootPage">
<ion-header translucent>
<ion-toolbar>
<ion-title>Nav</ion-title>
</ion-toolbar>
</ion-header>
<ion-content fullscreen>
<ion-list *ngFor="let page of techs">
<ion-item button (click)="showDetail(page)">
<ion-label>
<h3>{{page.title}}</h3>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
</ion-nav>
TS:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-list',
templateUrl: './list.page.html',
styleUrls: ['./list.page.scss'],
})
export class ListPage implements OnInit {
constructor() { }
ngOnInit() {
}
rootPage:any;
techs = [
{
'title': 'Angular',
'icon': 'angular',
'description': 'A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.',
'color': '#E63135'
},
{
'title': 'CSS3',
'icon': 'css3',
'description': 'The latest version of cascading stylesheets - the styling language of the web!',
'color': '#0CA9EA'
},
{
'title': 'HTML5',
'icon': 'html5',
'description': 'The latest version of the web\'s markup language.',
'color': '#F46529'
},
{
'title': 'JavaScript',
'icon': 'javascript',
'description': 'One of the most popular programming languages on the Web!',
'color': '#FFD439'
},
{
'title': 'Sass',
'icon': 'sass',
'description': 'Syntactically Awesome Stylesheets - a mature, stable, and powerful professional grade CSS extension.',
'color': '#CE6296'
},
{
'title': 'NodeJS',
'icon': 'nodejs',
'description': 'An open-source, cross-platform runtime environment for developing server-side Web applications.',
'color': '#78BD43'
},
{
'title': 'Python',
'icon': 'python',
'description': 'A clear and powerful object-oriented programming language!',
'color': '#3575AC'
},
{
'title': 'Markdown',
'icon': 'markdown',
'description': 'A super simple way to add formatting like headers, bold, bulleted lists, and so on to plain text.',
'color': '#412159'
},
{
'title': 'Tux',
'icon': 'tux',
'description': 'The official mascot of the Linux kernel!',
'color': '#000'
},
];
showDetail(page:any){
const tech = techs.find(tech => tech.title === title);
nav.push('nav-detail', { tech });
}
}
P.S: nav.push('nav-detail', { tech });
gives error (i dont know what is nav here)